<jupyter_start><jupyter_text>Welcome to day 3! First, some review<jupyter_code>count = 0
while count < 5:
    print("You're in the loop!")
    print(f"Count’s value is now {count}.")
    print("Enter 'quit' to exit the loop,")
    print("enter 'back' to go back to the start of the loop right now.")
    user_input = input()
    
    if user_input == "quit":
        break
    elif user_input == "back":
        continue
        
    count += 1
    
print("You have exited the loop.")
for count in [0, 1, 2, 3, 4]:
    print("You're in the loop!")
    print(f"Count’s value is now {count}.")
    print("Enter 'quit' to exit the loop,")
    print("enter 'back' to go back to the start of the loop right now,")
    print("or just hit 'Enter' to proceed to the rest of the loop.")
    user_input = input()
    
    if user_input == "quit":
        break
    elif user_input == "back":
        continue
        
    print("Welcome to the rest of the loop.")
    count += 10
    print(f"Count's value is now {count}.")
    
print("You have exited the loop.")
print(list(range(0, 5)))
flavors = ["chocolate", "vanilla", "strawberry"]
for flavor in flavors:
    print(f"Let's go out for {flavor} ice cream!")
for current_number in range(0, 11):
    print(f"The current number is {current_number}.")
for current_number in range(0, 21, 5):
    print(f"The current number is {current_number}.")
for current_number in range(20, -1, -1):
    print(f"The current number is {current_number}.")
for bottles in range(99, -1, -1):
    print(f"{bottles} bottles of beer on the wall")
    print(f"{bottles} bottles of beer")
    
    if bottles > 0:
        print("If one of those bottles should happen to fall...")
        print(f"{bottles - 1} bottles of beer on the wall")
    else:
        print("...and that's the end of the song!")
        
    print()<jupyter_output>99 bottles of beer on the wall
99 bottles of beer
If one of those bottles should happen to fall...
98 bottles of beer on the wall

98 bottles of beer on the wall
98 bottles of beer
If one of those bottles should happen to fall...
97 bottles of beer on the wall

97 bottles of beer on the wall
97 bottles of beer
If one of those bottles should happen to fall...
96 bottles of beer on the wall

96 bottles of beer on the wall
96 bottles of beer
If one of those bottles should happen to fall...
95 bottles of beer on the wall

95 bottles of beer on the wall
95 bottles of beer
If one of those bottles should happen to fall...
94 bottles of beer on the wall

94 bottles of beer on the wall
94 bottles of beer
If one of those bottles should happen to fall...
93 bottles of beer on the wall

93 bottles of beer on the wall
93 bottles of beer
If one of those bottles should happen to fall...
92 bottles of beer on the wall

92 bottles of beer on the wall
92 bottles of beer
If one of those bottles should ha[...]<jupyter_text>Functions<jupyter_code>def greet_user():
    print("Hello!")
    print("Welcome to the program.")

greet_user()
def greet_user_by_name(name):
    print(f"Hello, {name}!")
    
greet_user_by_name("Alice")
def greet_user_by_name_and_number_of_visits(name, num_visits):
    print(f"Hello, {name.upper()}!")
    print(f"This is visit number {num_visits} for you.")
          
greet_user_by_name_and_number_of_visits("Bernadette", 5)
greet_user_by_name_and_number_of_visits(name="Catherine", num_visits=7)
greet_user_by_name_and_number_of_visits(num_visits=10, name="Darla")<jupyter_output>Hello, Darla!
This is visit number 10 for you.<jupyter_text>Lists<jupyter_code>g8_countries = ["UK", "France", "Germany", "Italy", "Russia", "Japan", "United States"]
print(g8_countries)
# Get the first country in the list
first_country = g8_countries[0]
print(first_country)
# Get the last country in the list
last_country = g8_countries[-1]
print(last_country)
# Get the 3rd country in the list
print(g8_countries[2])
# Get the 2nd-last country in the list
print(g8_countries[-2])
print(g8_countries)
g8_countries[0] = "United Kingdom"
print(g8_countries)
print(len(g8_countries))
print(len(g8_countries[0]))
print(len("United Kingdom"))
g8_countries.append("Canada")
print(len(g8_countries))
print(g8_countries)
g8_countries.append("Wakanda")
print(g8_countries)
del g8_countries[8]
print(g8_countries)
score = 5
print(score)
del score
print(score)
g8_countries = ['United Kingdom', 'Germany', 'Italy', 'France', 'Russia', 'Japan', 'United States', 'Canada']
print(g8_countries)
g8_countries.insert(1, "China")
print(g8_countries)
# Move China from position 1 to position 4
country_to_move = g8_countries.pop(1)
print(country_to_move)
g8_countries.insert(4, country_to_move)
print(g8_countries)
colors = ["red", "green", "blue", "orange"]
print(colors)
del colors[2]
print(colors)
colors = ["red", "green", "blue", "orange"]
print(colors)
colors.remove("blue")
print(colors)
colors.remove("pink")
colors = ["red", "green", "green", "blue", "orange"]
print(colors)
colors.remove("green")
print(colors)
print(f"Is blue in the list?: {'blue' in colors}")
print(f"Is pink in the list?: {'pink' in colors}")
colors = ["red", "green", "green", "blue", "orange", "green"]
print(f"Is green in the list?: {'green' in colors}")
green_count = colors.count("green")
print(f"Green appears {green_count} times in the list.")
pink_count = colors.count("pink")
print(f"Pink appears {pink_count} times in the list.")
red_count = colors.count("red")
print(f"Red appears {red_count} times in the list.")
print(colors)
print(f"Blue is in position {colors.index('blue')}")
print(f"Green is in position {colors.index('green')}")
print(f"Pink is in position {colors.index('pink')}")
if "green" in colors:
    print(f"The first instance of green is at position {colors.index('green')}")
if "pink" in colors:
    print(f"The first instance of pink is at position {colors.index('pink')}")
else:
    print("Pink is not in the list of colors!")
print("Before sorting the list:")
for country in g8_countries:
    print(country)

g8_countries.sort()

print("\n\nAfter sorting the list:")
for country in g8_countries:
    print(country)
print(f"Before reversing the list:\n{g8_countries}")
g8_countries.reverse()
print(f"\nAfter reversing the list:\n{g8_countries}")
numbers = [45, 38, 2, 99, -4, 82, 44]
numbers.sort()
print(numbers)
numbers.reverse()
print(numbers)
print(g8_countries)
for country in g8_countries:
    if country == "China":
        continue
    print(f"{country} is a G8 country.")<jupyter_output>United States is a G8 country.
United Kingdom is a G8 country.
Russia is a G8 country.
Japan is a G8 country.
Italy is a G8 country.
Germany is a G8 country.
France is a G8 country.
Canada is a G8 country.<jupyter_text>Slices<jupyter_code>print(g8_countries)
first_three_countries = g8_countries[0:3]
print(first_three_countries)
japan_italy_germany = g8_countries[3:6]
print(japan_italy_germany)
first_four_countries = g8_countries[:4]
print(first_four_countries)
last_countries = g8_countries[6:]
print(last_countries)
print(g8_countries[0])
print(g8_countries[-1])
print(g8_countries)
print(g8_countries[1:-1])
way_out_slice = g8_countries[25:200]
print(way_out_slice)
tic_tac_toe_board = [["X", "O", "X"], ["X", "Y", "X"], ["O", "O", "O"]]
print(tic_tac_toe_board)
print(tic_tac_toe_board[1][1])
def show_only_countries_with_long_names(country_list):
    for country in country_list:
        if len(country) > 6:
            print(country)
            
show_only_countries_with_long_names(g8_countries)
def extract_countries_with_long_names(country_list):
    result = []
    for country in country_list:
        if len(country) > 6:
            result.append(country)
    return result
            
long_named_countries = extract_countries_with_long_names(g8_countries)
print(long_named_countries)<jupyter_output>['United States', 'United Kingdom', 'Germany']<jupyter_text>Dictionaries<jupyter_code>cholula_name = "Cholula"
cholula_price = 2.99
cholula_scovilles = 3600

da_bomb_name = "Da Bomb Original Insanity"
da_bomb_price = 8.99
da_bomb_scovilles = 135600


cholula = {"name": "Cholula", "price": 2.99, "scovilles": 2_500}
print(cholula)
print(cholula["name"])
print(cholula["price"])
print(cholula["scovilles"])
franks = {"name": "<NAME>", "price": 2.79, "scovilles": 450}
print(franks)
print(franks["scovilles"])
print(franks["price"])
last_dab = {"name": "The Last Dab", "price": 20.00, "scovilles": 2_000_000}
print(last_dab)
hot_sauces = [franks, cholula, last_dab]
print(hot_sauces)
print(hot_sauces[1]["price"])
print(hot_sauces[2]["scovilles"])
def sauce_heat(sauce):
    return sauce["scovilles"]

print(sauce_heat(franks))
hot_sauces.sort(key=sauce_heat)
print(hot_sauces)
def sauce_name(sauce):
    return sauce["name"]

hot_sauces.sort(key=sauce_name)
print(hot_sauces)<jupyter_output>[{'name': 'Cholula', 'price': 2.99, 'scovilles': 2500}, {'name': "<NAME>", 'price': 2.79, 'scovilles': 450}, {'name': 'The Last Dab', 'price': 20.0, 'scovilles': 2000000}]
{'fraction_non_alphanumeric': 0.13207124453903887, 'fraction_numerical': 0.02778088943654083, 'mean_word_length': 4.944074567243675, 'pattern_counts': {'":': 14, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '448026', 'license': 'MIT', 'n_tokens_mistral': 3344, 'n_tokens_neox': 3141, 'n_words': 946, 'path': 'Untitled.ipynb', 'repo_name': 'AccordionGuy/Intro-to-Python-2020', 'size': '8945'}