<jupyter_start><jupyter_text>_The following excercises are adapted from <NAME>'s Introducing Python_ 1- Create a list called years_list, starting with the year of your birth, and each year thereafter until the year of your fifth birthday. For example, if you were born in 1980. the list would be years_list = [1980, 1981, 1982, 1983, 1984, 1985]<jupyter_code>years_list = [1980, 1981, 1982, 1983, 1984, 1985]
years_list = list(range(1980, 1986))<jupyter_output><empty_output><jupyter_text>2- In which year in years_list was your third birthday? Remember, you were 0 years of age for your first year.<jupyter_code>years_list[3]<jupyter_output><empty_output><jupyter_text>3- In which year in years_list were you the oldest?<jupyter_code>years_list[-1]<jupyter_output><empty_output><jupyter_text>4- Make a list called things with these three strings as elements: "mozzarella", "cinderella", "salmonella".<jupyter_code>things = ["mozzarella", "cinderella", "salmonella"]<jupyter_output><empty_output><jupyter_text>5- Capitalize the element in things that refers to a person and then print the list. Did it change the element in the list?<jupyter_code>things[1] = things[1].capitalize()
things<jupyter_output><empty_output><jupyter_text>6- Make the cheesy element of things all uppercase and then print the list.<jupyter_code>things[0] = things[0].upper()
things<jupyter_output><empty_output><jupyter_text>7- Delete the disease element from things, collect your Nobel Prize, and print the list.<jupyter_code>things.pop()
things
things = ["mozzarella", "cinderella", "salmonella"]
things = things[0:2]
things
things = ["mozzarella", "cinderella", "salmonella"]
things[-1:]=[]
things<jupyter_output><empty_output><jupyter_text>8- Create a list called surprise with the elements "Groucho", "Chico", and "Harpo".<jupyter_code>surprise = ["Groucho", "Chico",  "Harpo"]<jupyter_output><empty_output><jupyter_text>9- Lowercase the last element of the surprise list, reverse it, and then capitalize it.<jupyter_code>surprise[-1].lower()[::-1].capitalize()
# or spell it in details
last_element = surprise[-1]
last_element_in_lower_case = last_element.lower()
reversed_element = last_element_in_lower_case[::-1]
reversed_element.capitalize()<jupyter_output><empty_output><jupyter_text>10- Make an English-to-French dictionary called e2f and print it. Here are your starter words: dog is chien, cat is chat, and walrus is morse.<jupyter_code>e2f = {'dog':'chien', 'cat':'chat', 'walrus':'morse'}<jupyter_output><empty_output><jupyter_text>11- Using your three-word dictionary e2f, print the French word for walrus.<jupyter_code>print(e2f['walrus'])<jupyter_output>morse<jupyter_text>12- Make a French-to-English dictionary called f2e from e2f. Use the items method.<jupyter_code>e2f.items()
# each item is a tuple
f2e = {}
for item in e2f.items():
    key = item[0]
    value = item[1]
    f2e[value]=key
f2e
#another way to do it
f2e = {}
for k in e2f:
    v = e2f[k]
    f2e[v]=k
f2e
#another way to do it
f2e = { v:k for k,v in e2f.items() }<jupyter_output><empty_output><jupyter_text>13- Using f2e, print the English equivalent of the French word chien.<jupyter_code>f2e['chien']<jupyter_output><empty_output><jupyter_text>14- Make and print a set of English words from the keys in e2f.<jupyter_code>english_words = set(e2f.keys())
english_words<jupyter_output><empty_output><jupyter_text>15- Make a multilevel dictionary called life. Use these strings for the topmost keys: 'animals', 'plants', and 'other'. Make the 'animals' key refer to another dictionary with the keys 'cats', 'octopi', and 'emus'. Make the 'cats' key refer to a list of strings with the values 'Henri', 'Grumpy', and 'Lucy'. Make all the other keys refer to empty dictionaries.<jupyter_code>life = {'animals': 
            {
                'cats': ['Henri', 'Grumpy', 'Lucy'],
                'octopi': {},
                'emus': {}
            }, 
        'plants': {}, 
        'other': {}
       }
life<jupyter_output><empty_output><jupyter_text>16- Print the top-level keys of life.<jupyter_code>life.keys()
for k in life.keys():
    print(k)<jupyter_output>animals
plants
other<jupyter_text>17- Print the keys for life['animals'].<jupyter_code>life['animals'].keys()
for k in life['animals'].keys():
    print(k)<jupyter_output>cats
octopi
emus<jupyter_text>18- Print the values for life['animals']['cats'].<jupyter_code>life['animals']['cats']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1244654512716633, 'fraction_numerical': 0.028134143596668916, 'mean_word_length': 5.712990936555891, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 71, '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': '18', 'dir': 'jupyter-structured-clean-dedup', 'id': '311267', 'license': 'MIT', 'n_tokens_mistral': 1657, 'n_tokens_neox': 1523, 'n_words': 432, 'path': '09-warmup-solution_built_in_data_structures.ipynb', 'repo_name': 'hanisaf/advanced-data-management-and-analytics', 'size': '4451'}