<jupyter_start><jupyter_text>TRY IT YOURSELF6-1. Person: Use a dictionary to store information about a person you know. Store their first name, last name, age, and the city in which they live. You should have keys such as first_name, last_name, age, and city. Print each piece of information stored in your dictionary.<jupyter_code>person = {"name":"David","last_name":"Calabuig","age":"45","city":"Valencia"}
person.keys()
person.values()
print(person)<jupyter_output>{'name': 'David', 'last_name': 'Calabuig', 'age': '45', 'city': 'Valencia'}<jupyter_text>6-2. Favorite Numbers: Use a dictionary to store people’s favorite numbers. Think of five names, and use them as keys in your dictionary. Think of a favorite number for each person, and store each as a value in your dictionary. Print each person’s name and their favorite number. For even more fun, poll a few friends and get some actual data for your program.<jupyter_code>fav_numbers={"David":"8","Almu":"10","Mireia":"13","Paula":"2","Oto":"21"}
print(f"\n",fav_numbers.items())<jupyter_output>dict_items([('David', '8'), ('Almu', '10'), ('Mireia', '13'), ('Paula', '2'), ('Oto', '21')])<jupyter_text>6-3. Glossary: A Python dictionary can be used to model an actual dictionary. However, to avoid confusion, let’s call it a glossary.Think of five programming words you’ve learned about in the previous chapters. Use these words as the keys in your glossary, and store their meanings as values.Print each word and its meaning as neatly formatted output. You might print the word followed by a colon and then its meaning, or print the word on one line and then print its meaning indented on a second line. Use the newline character (\n) to insert a blank line between each word-meaning pair in your output.<jupyter_code>glosario = {"int":"entero","list":"lista","if":"si","while":"mientras","float":"flotante"}
print ("int:",glosario["int"])
print ("list:",glosario["list"])
print ("if:",glosario["if"])
print ("while:",glosario["while"])
print ("float:",glosario["float"])<jupyter_output>int: entero
list: lista
if: si
while: mientras
float: flotante<jupyter_text>6-4. Glossary 2: Now that you know how to loop through a dictionary, clean up the code from Exercise 6-3 (page 99) by replacing your series of print() calls with a loop that runs through the dictionary’s keys and values. When you’re  sure that your loop works, add five more Python terms to your glossary. When  you run your program again, these new words and meanings should automatically  be included in the output.<jupyter_code>glosario={"int":"entero","list":"lista","if":"si","while":"mientras","float":"flotante","True":"Verdadero","False":"Falso","for":"desde","dict":"diccionario"}
for i, j in glosario.items():
    print(f"\nKey:{i}",f"Value:{j}")<jupyter_output><empty_output><jupyter_text>6-5. Rivers: Make a dictionary containing three major rivers and the country each river runs through. One key-value pair might be 'nile': 'egypt'.Use a loop to print a sentence about each river, such as The Nile runs through Egypt.Use a loop to print the name of each river included in the dictionary.Use a loop to print the name of each country included in the dictionary.<jupyter_code>rios={"nilo":"Egipto","amazonas":"Brasil","yantgse":"China"}
for i,j in rios.items():
    if i == "nilo":
        print("El",i,"atraviesa",j)
    if i == "amazonas":
        print("El",i,"atraviesa",j)
    if i == "yantgse":
        print("El",i,"atraviesa",j)
for i,j in rios.items():
    print("El nombre del rio es:",i)
    print("El nombre del país que atraviesa el rio es:",j)<jupyter_output><empty_output><jupyter_text>6-6. Polling: Use the code in favorite_languages.py (page 97).Make a list of people who should take the favorite languages poll. Include some names that are already in the dictionary and some that are not.Loop through the list of people who should take the poll. If they have already taken the poll, print a message thanking them for responding. If they have not  yet taken the poll, print a message inviting them to take the poll.<jupyter_code>dict_idiomas={"David":"Castellano","Mireia":"Ingles","Paula":"Chino","Almu":"Aleman"}
lista_en=["David","Pedro","Almu","Antonio","Juan"]
#for i in dict_idiomas:
for j in lista_en:
        if j in dict_idiomas:
            print("Esta persona,",j, "ya ha participado en esta encuesta.")
        else:
            print("Preguntale a", j,"si quiere participar en la encuesta.")<jupyter_output><empty_output><jupyter_text>6-7. People: Start with the program you wrote for Exercise 6-1 (page 99).   Make two new dictionaries representing different people, and store all three   dictionaries in a list called people. Loop through your list of people. As   you loop through the list, print everything you know about each person.<jupyter_code>person = {"name":"David","last_name":"Calabuig","age":"45","city":"Valencia"}
person2 = {"name":"Almu","last_name":"Gonzalez","age":"46","city":"Valencia"}
person3 = {"name":"Mireia","last_name":"Calabuig","age":"12","city":"Valencia"}
personas = [person,person2,person3]
for i in personas:
    print("Todo lo que se de ti es:",i)<jupyter_output><empty_output><jupyter_text>6-8. Pets: Make several dictionaries, where each dictionary represents a different pet. In each dictionary, include the kind of animal and the owner’s name. Store these dictionaries in a list called pets. Next, loop through your list and as you do, print everything you know about each pet.<jupyter_code>mascota={"animal":"perro","dueño":"David"}
mascota2={"animal":"gato","dueño":"Almu"}
mascota3={"animal":"periquito","dueño":"Paula"}
mascotas=[mascota,mascota2,mascota3]
for i in mascotas:
    print("Todo lo que se de la mascota es:",i)<jupyter_output><empty_output><jupyter_text>6-9. Favorite Places: Make a dictionary called favorite_places. Think of three names to use as keys in the dictionary, and store one to three favorite places  for each person. To make this exercise a bit more interesting, ask some   friends to name a few of their favorite places. Loop through the dictionary,   and print each person’s name and their favorite places.<jupyter_code>lugares_fav={"David":"Reikiavik, NY","Almu":"NY, Paris, San Torini","Paula":"Tokio, San Jose"}

for a,b in lugares_fav.items():
    print("Los lugares favoritos de",a,"son:",b)<jupyter_output><empty_output><jupyter_text>6-10. Favorite Numbers: Modify your program from Exercise 6-2 (page 99) so each person can have more than one favorite number. Then print each person’s name along with their favorite numbers.<jupyter_code>fav_numbers={"David":"8, 18, 21","Almu":"10 , 13, 27","Mireia":"13, 21","Paula":"2, 8, 10","Oto":"21, 57"}
for nom,num in fav_numbers.items():
    print("Los numeros favoritos de",nom,"son:",num)<jupyter_output><empty_output><jupyter_text>6-11. Cities: Make a dictionary called cities. Use the names of three cities as keys in your dictionary. Create a dictionary of information about each city  and include the country that the city is in, its approximate population, and  one fact about that city. The keys for each city’s dictionary should be  something like country, population, and fact. Print the name of each city and  all of the information you have stored about it.<jupyter_code>ciudades={"Londres","Valencia","Gales"}
#ciudades_des={{"Pais":"Inglaterra","Poblacion":"28.000.000","dato":"niebla"},{"Pais":"España","poblacion":"47.000.000","dato":"sol"},{"Pais":"Francia","poblacion":"42.000.000","dato":"rugby"}}
Londres={"Pais":"Inglaterra","Poblacion":"28.000.000","dato":"niebla"}

for j in ciudades:
        for i,k in Londres.items():
            print("La ciudad es", j, "sus datos son, pais:", Londres.values[1], ",poblacion:",k,"hecho:")

        print(j)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13619426956186562, 'fraction_numerical': 0.016574585635359115, 'mean_word_length': 5.816112084063048, 'pattern_counts': {'":': 71, '<': 42, '<?xml version=': 0, '>': 42, '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': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '514474', 'license': 'MIT', 'n_tokens_mistral': 2478, 'n_tokens_neox': 2371, 'n_words': 878, 'path': '02_PYTHON/week05/pra/Tema6_libro.ipynb', 'repo_name': 'dacafra11/THE_BRIDGE_DS_ALUMNI_feb22', 'size': '7783'}