Skip to main content

Command Palette

Search for a command to run...

ACTIVITY 27: Master the Python Dictionaries Data Structures

Published
49 min readView as Markdown
  1. Create 50 Python Files

    • Create 50 Python files, each focusing on dictionary manipulation.
  2. GitHub Commit Requirement

    • You must make 50 commits in your GitHub repository, with each commit corresponding to the creation or update of a Python file.

    • Example commit messages:

  3. File Requirements

    • Each Python file should involve dictionary manipulation.
  4. Create documentation on medium.com or hashnode.com Explain your code and include the github repository link

  5. Don't use AI to generate your code. Instead, focus on mastering and understanding list data structures in Python.


1. student_grades_dict.py

  1. Create a dictionary of 5 students and their corresponding grades.

  2. Print the entire dictionary.

  3. Access and print the grade of the 3rd student.

    • Example: print("Grade of third student:", dict['Student3'])
  4. Update the grade of the 2nd student.

    • Example: dict['Student2'] = 'A'
  5. Delete the entry of the 5th student.

    • Example: del dict['Student5']
  6. Print the last key-value pair in the dictionary.

# Create a dictionary of 5 students and their corresponding grades
student_grades_dict = {
    'Student1': 'B',
    'Student2': 'C',
    'Student3': 'A',
    'Student4': 'B',
    'Student5': 'D'
}

# Print the entire dictionary
print("Student Grades Dictionary:", student_grades_dict)

# Access and print the grade of the 3rd student
print("Grade of third student:", student_grades_dict['Student3'])

# Update the grade of the 2nd student
student_grades_dict['Student2'] = 'A'

# Print updated dictionary
print("Updated Student Grades Dictionary:", student_grades_dict)

# Delete the entry of the 5th student
del student_grades_dict['Student5']

# Print updated dictionary after deletion
print("Dictionary after deleting Student5:", student_grades_dict)

# Print the last key-value pair in the dictionary
last_key = list(student_grades_dict.keys())[-1]
last_value = student_grades_dict[last_key]
print(f"Last key-value pair in the dictionary: {last_key}: {last_value}")


2. animal_sounds_dict.py

  1. Create a dictionary of 8 animals and their corresponding sounds.

  2. Print the entire dictionary.

  3. Access and print the sound of the 4th animal.

  4. Update the sound of the 7th animal.

  5. Delete the 5th animal from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 8 animals and their corresponding sounds
animal_sounds_dict = {
    'Dog': 'Bark',
    'Cat': 'Meow',
    'Cow': 'Moo',
    'Duck': 'Quack',
    'Sheep': 'Baa',
    'Horse': 'Neigh',
    'Pig': 'Oink',
    'Lion': 'Roar'
}

# Print the entire dictionary
print("The entire dictionary:", animal_sounds_dict)

# Access and print the sound of the 4th animal (Duck)
fourth_animal_sound = list(animal_sounds_dict.values())[3]  # Index 3 for the 4th item
print("\nThe sound of the 4th animal (Duck):", fourth_animal_sound)

# Update the sound of the 7th animal (Pig)
animal_sounds_dict['Pig'] = 'Grunt'
print("\nUpdated sound of the 7th animal (Pig):", animal_sounds_dict['Pig'])

# Delete the 5th animal (Sheep) from the dictionary
del animal_sounds_dict['Sheep']
print("\nDictionary after deleting the 5th animal (Sheep):", animal_sounds_dict)

# Print the last key-value pair in the dictionary
last_key = list(animal_sounds_dict.keys())[-1]
last_value = animal_sounds_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))


3. city_population_dict.py

  1. Create a dictionary of 10 cities and their corresponding population.

  2. Print the entire dictionary.

  3. Access and print the population of the 6th city.

  4. Update the population of the 3rd city.

  5. Delete the 9th city from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 cities and their corresponding population
city_population_dict = {
    'New York': 8419600,
    'Los Angeles': 3980400,
    'Chicago': 2716000,
    'Houston': 2328000,
    'Phoenix': 1690000,
    'Philadelphia': 1584200,
    'San Antonio': 1547250,
    'San Diego': 1423851,
    'Dallas': 1341075,
    'San Jose': 1026908
}

# Print the entire dictionary
print("The entire dictionary:", city_population_dict)

# Access and print the population of the 6th city (Philadelphia)
sixth_city_population = list(city_population_dict.values())[5]  # Index 5 for the 6th item
print("\nThe population of the 6th city (Philadelphia):", sixth_city_population)

# Update the population of the 3rd city (Chicago)
city_population_dict['Chicago'] = 2800000
print("\nUpdated population of the 3rd city (Chicago):", city_population_dict['Chicago'])

# Delete the 9th city (Dallas) from the dictionary
del city_population_dict['Dallas']
print("\nDictionary after deleting the 9th city (Dallas):", city_population_dict)

# Print the last key-value pair in the dictionary
last_key = list(city_population_dict.keys())[-1]
last_value = city_population_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))


4. country_capital_dict.py

  1. Create a dictionary of 12 countries and their capitals.

  2. Print the entire dictionary.

  3. Access and print the capital of the 5th country.

  4. Update the capital of the 8th country.

  5. Delete the 11th country from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 12 countries and their corresponding capitals
country_capital_dict = {
    'United States': 'Washington, D.C.',
    'Canada': 'Ottawa',
    'Mexico': 'Mexico City',
    'Brazil': 'Brasília',
    'United Kingdom': 'London',
    'France': 'Paris',
    'Germany': 'Berlin',
    'Italy': 'Rome',
    'Spain': 'Madrid',
    'Australia': 'Canberra',
    'Japan': 'Tokyo',
    'India': 'New Delhi'
}

# Print the entire dictionary
print("The entire dictionary:", country_capital_dict)

# Access and print the capital of the 5th country (United Kingdom)
fifth_country_capital = list(country_capital_dict.values())[4]  # Index 4 for the 5th item
print("\nThe capital of the 5th country (United Kingdom):", fifth_country_capital)

# Update the capital of the 8th country (Italy)
country_capital_dict['Italy'] = 'Milan'
print("\nUpdated capital of the 8th country (Italy):", country_capital_dict['Italy'])

# Delete the 11th country (Japan) from the dictionary
del country_capital_dict['Japan']
print("\nDictionary after deleting the 11th country (Japan):", country_capital_dict)

# Print the last key-value pair in the dictionary
last_key = list(country_capital_dict.keys())[-1]
last_value = country_capital_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

5. programming_languages_dict.py

  1. Create a dictionary of 7 programming languages and their developers.

  2. Print the entire dictionary.

  3. Access and print the developer of the 4th programming language.

  4. Update the developer of the 6th programming language.

  5. Delete the 2nd programming language from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 7 programming languages and their developers
programming_languages_dict = {
    'Python': 'Guido van Rossum',
    'Java': 'James Gosling',
    'C++': 'Bjarne Stroustrup',
    'JavaScript': 'Brendan Eich',
    'Ruby': 'Yukihiro Matsumoto',
    'PHP': 'Rasmus Lerdorf',
    'Swift': 'Chris Lattner'
}

# Print the entire dictionary
print("The entire dictionary:", programming_languages_dict)

# Access and print the developer of the 4th programming language (JavaScript)
fourth_language_developer = list(programming_languages_dict.values())[3]  # Index 3 for the 4th item
print("\nThe developer of the 4th programming language (JavaScript):", fourth_language_developer)

# Update the developer of the 6th programming language (PHP)
programming_languages_dict['PHP'] = 'Andi Gutmans'
print("\nUpdated developer of the 6th programming language (PHP):", programming_languages_dict['PHP'])

# Delete the 2nd programming language (Java) from the dictionary
del programming_languages_dict['Java']
print("\nDictionary after deleting the 2nd programming language (Java):", programming_languages_dict)

# Print the last key-value pair in the dictionary
last_key = list(programming_languages_dict.keys())[-1]
last_value = programming_languages_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

6. car_brands_dict.py

  1. Create a dictionary of 10 car brands and their country of origin.

  2. Print the entire dictionary.

  3. Access and print the country of origin of the 3rd car brand.

  4. Update the country of origin of the 7th car brand.

  5. Delete the 8th car brand from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 car brands and their country of origin
car_brands_dict = {
    'Toyota': 'Japan',
    'BMW': 'Germany',
    'Ford': 'USA',
    'Chevrolet': 'USA',
    'Audi': 'Germany',
    'Honda': 'Japan',
    'Hyundai': 'South Korea',
    'Nissan': 'Japan',
    'Kia': 'South Korea',
    'Ferrari': 'Italy'
}

# Print the entire dictionary
print("The entire dictionary:", car_brands_dict)

# Access and print the country of origin of the 3rd car brand (Ford)
third_car_country = list(car_brands_dict.values())[2]  # Index 2 for the 3rd item
print("\nThe country of origin of the 3rd car brand (Ford):", third_car_country)

# Update the country of origin of the 7th car brand (Hyundai)
car_brands_dict['Hyundai'] = 'South Korea (Updated)'
print("\nUpdated country of origin of the 7th car brand (Hyundai):", car_brands_dict['Hyundai'])

# Delete the 8th car brand (Nissan) from the dictionary
del car_brands_dict['Nissan']
print("\nDictionary after deleting the 8th car brand (Nissan):", car_brands_dict)

# Print the last key-value pair in the dictionary
last_key = list(car_brands_dict.keys())[-1]
last_value = car_brands_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

7. book_authors_dict.py

  1. Create a dictionary of 12 books and their authors.

  2. Print the entire dictionary.

  3. Access and print the author of the 9th book.

  4. Update the author of the 5th book.

  5. Delete the 3rd book from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 12 books and their authors
book_authors_dict = {
    '1984': 'George Orwell',
    'To Kill a Mockingbird': 'Harper Lee',
    'The Great Gatsby': 'F. Scott Fitzgerald',
    'Moby-Dick': 'Herman Melville',
    'Pride and Prejudice': 'Jane Austen',
    'War and Peace': 'Leo Tolstoy',
    'The Catcher in the Rye': 'J.D. Salinger',
    'The Hobbit': 'J.R.R. Tolkien',
    'The Lord of the Rings': 'J.R.R. Tolkien',
    'Crime and Punishment': 'Fyodor Dostoevsky',
    'Brave New World': 'Aldous Huxley',
    'Frankenstein': 'Mary Shelley'
}

# Print the entire dictionary
print("The entire dictionary:", book_authors_dict)

# Access and print the author of the 9th book (The Lord of the Rings)
ninth_book_author = list(book_authors_dict.values())[8]  # Index 8 for the 9th item
print("\nThe author of the 9th book (The Lord of the Rings):", ninth_book_author)

# Update the author of the 5th book (Pride and Prejudice)
book_authors_dict['Pride and Prejudice'] = 'Updated Author'
print("\nUpdated author of the 5th book (Pride and Prejudice):", book_authors_dict['Pride and Prejudice'])

# Delete the 3rd book (The Great Gatsby) from the dictionary
del book_authors_dict['The Great Gatsby']
print("\nDictionary after deleting the 3rd book (The Great Gatsby):", book_authors_dict)

# Print the last key-value pair in the dictionary
last_key = list(book_authors_dict.keys())[-1]
last_value = book_authors_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

8. fruit_colors_dict.py

  1. Create a dictionary of 8 fruits and their corresponding colors.

  2. Print the entire dictionary.

  3. Access and print the color of the 6th fruit.

  4. Update the color of the 4th fruit.

  5. Delete the 7th fruit from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 8 fruits and their corresponding colors
fruit_colors_dict = {
    'Apple': 'Red',
    'Banana': 'Yellow',
    'Orange': 'Orange',
    'Grapes': 'Purple',
    'Blueberry': 'Blue',
    'Strawberry': 'Red',
    'Pineapple': 'Yellow',
    'Watermelon': 'Green'
}

# Print the entire dictionary
print("The entire dictionary:", fruit_colors_dict)

# Access and print the color of the 6th fruit (Strawberry)
sixth_fruit_color = list(fruit_colors_dict.values())[5]  # Index 5 for the 6th item
print("\nThe color of the 6th fruit (Strawberry):", sixth_fruit_color)

# Update the color of the 4th fruit (Grapes)
fruit_colors_dict['Grapes'] = 'Green'
print("\nUpdated color of the 4th fruit (Grapes):", fruit_colors_dict['Grapes'])

# Delete the 7th fruit (Pineapple) from the dictionary
del fruit_colors_dict['Pineapple']
print("\nDictionary after deleting the 7th fruit (Pineapple):", fruit_colors_dict)

# Print the last key-value pair in the dictionary
last_key = list(fruit_colors_dict.keys())[-1]
last_value = fruit_colors_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

9. movie_directors_dict.py

  1. Create a dictionary of 10 movies and their directors.

  2. Print the entire dictionary.

  3. Access and print the director of the 5th movie.

  4. Update the director of the 9th movie.

  5. Delete the 7th movie from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 movies and their directors
movie_directors_dict = {
    'Inception': 'Christopher Nolan',
    'The Dark Knight': 'Christopher Nolan',
    'Interstellar': 'Christopher Nolan',
    'The Matrix': 'Wachowskis',
    'Pulp Fiction': 'Quentin Tarantino',
    'The Shawshank Redemption': 'Frank Darabont',
    'The Godfather': 'Francis Ford Coppola',
    'Fight Club': 'David Fincher',
    'Forrest Gump': 'Robert Zemeckis',
    'The Lion King': 'Roger Allers, Rob Minkoff'
}

# Print the entire dictionary
print("The entire dictionary:", movie_directors_dict)

# Access and print the director of the 5th movie (Pulp Fiction)
fifth_movie_director = list(movie_directors_dict.values())[4]  # Index 4 for the 5th item
print("\nThe director of the 5th movie (Pulp Fiction):", fifth_movie_director)

# Update the director of the 9th movie (Forrest Gump)
movie_directors_dict['Forrest Gump'] = 'Updated Director'
print("\nUpdated director of the 9th movie (Forrest Gump):", movie_directors_dict['Forrest Gump'])

# Delete the 7th movie (The Godfather) from the dictionary
del movie_directors_dict['The Godfather']
print("\nDictionary after deleting the 7th movie (The Godfather):", movie_directors_dict)

# Print the last key-value pair in the dictionary
last_key = list(movie_directors_dict.keys())[-1]
last_value = movie_directors_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

10. software_companies_dict.py

  1. Create a dictionary of 10 software companies and their headquarters.

  2. Print the entire dictionary.

  3. Access and print the headquarters of the 3rd company.

  4. Update the headquarters of the 8th company.

  5. Delete the 9th company from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 software companies and their headquarters
software_companies_dict = {
    'Microsoft': 'Redmond, Washington, USA',
    'Apple': 'Cupertino, California, USA',
    'Google': 'Mountain View, California, USA',
    'Amazon': 'Seattle, Washington, USA',
    'Facebook': 'Menlo Park, California, USA',
    'Adobe': 'San Jose, California, USA',
    'IBM': 'Armonk, New York, USA',
    'Oracle': 'Redwood City, California, USA',
    'SAP': 'Walldorf, Germany',
    'Twitter': 'San Francisco, California, USA'
}

# Print the entire dictionary
print("The entire dictionary:", software_companies_dict)

# Access and print the headquarters of the 3rd company (Google)
third_company_headquarters = list(software_companies_dict.values())[2]  # Index 2 for the 3rd item
print("\nThe headquarters of the 3rd company (Google):", third_company_headquarters)

# Update the headquarters of the 8th company (Oracle)
software_companies_dict['Oracle'] = 'Austin, Texas, USA'
print("\nUpdated headquarters of the 8th company (Oracle):", software_companies_dict['Oracle'])

# Delete the 9th company (SAP) from the dictionary
del software_companies_dict['SAP']
print("\nDictionary after deleting the 9th company (SAP):", software_companies_dict)

# Print the last key-value pair in the dictionary
last_key = list(software_companies_dict.keys())[-1]
last_value = software_companies_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

11. sports_players_dict.py

  1. Create a dictionary of 10 sports and their most famous players.

  2. Print the entire dictionary.

  3. Access and print the player of the 4th sport.

  4. Update the player of the 6th sport.

  5. Delete the 10th sport from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 sports and their most famous players
sports_players_dict = {
    'Football': 'Lionel Messi',
    'Basketball': 'Michael Jordan',
    'Tennis': 'Roger Federer',
    'Cricket': 'Sachin Tendulkar',
    'Baseball': 'Babe Ruth',
    'Boxing': 'Muhammad Ali',
    'Golf': 'Tiger Woods',
    'Rugby': 'Jonah Lomu',
    'Hockey': 'Wayne Gretzky',
    'Athletics': 'Usain Bolt'
}

# Print the entire dictionary
print("The entire dictionary:", sports_players_dict)

# Access and print the player of the 4th sport (Cricket)
fourth_sport_player = list(sports_players_dict.values())[3]  # Index 3 for the 4th item
print("\nThe player of the 4th sport (Cricket):", fourth_sport_player)

# Update the player of the 6th sport (Boxing)
sports_players_dict['Boxing'] = 'Floyd Mayweather'
print("\nUpdated player of the 6th sport (Boxing):", sports_players_dict['Boxing'])

# Delete the 10th sport (Athletics) from the dictionary
del sports_players_dict['Athletics']
print("\nDictionary after deleting the 10th sport (Athletics):", sports_players_dict)

# Print the last key-value pair in the dictionary
last_key = list(sports_players_dict.keys())[-1]
last_value = sports_players_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

12. university_courses_dict.py

  1. Create a dictionary of 8 universities and their popular courses.

  2. Print the entire dictionary.

  3. Access and print the course of the 3rd university.

  4. Update the course of the 5th university.

  5. Delete the 7th university from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 8 universities and their popular courses
university_courses_dict = {
    'Harvard University': 'Computer Science',
    'Stanford University': 'Electrical Engineering',
    'Massachusetts Institute of Technology': 'Physics',
    'University of California, Berkeley': 'Biology',
    'University of Oxford': 'Law',
    'Cambridge University': 'Mathematics',
    'University of Chicago': 'Economics',
    'Princeton University': 'History'
}

# Print the entire dictionary
print("The entire dictionary:", university_courses_dict)

# Access and print the course of the 3rd university (Massachusetts Institute of Technology)
third_university_course = list(university_courses_dict.values())[2]  # Index 2 for the 3rd item
print("\nThe course of the 3rd university (Massachusetts Institute of Technology):", third_university_course)

# Update the course of the 5th university (University of Oxford)
university_courses_dict['University of Oxford'] = 'Philosophy'
print("\nUpdated course of the 5th university (University of Oxford):", university_courses_dict['University of Oxford'])

# Delete the 7th university (University of Chicago) from the dictionary
del university_courses_dict['University of Chicago']
print("\nDictionary after deleting the 7th university (University of Chicago):", university_courses_dict)

# Print the last key-value pair in the dictionary
last_key = list(university_courses_dict.keys())[-1]
last_value = university_courses_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

13. element_symbols_dict.py

  1. Create a dictionary of 10 elements and their chemical symbols.

  2. Print the entire dictionary.

  3. Access and print the symbol of the 6th element.

  4. Update the symbol of the 8th element.

  5. Delete the 9th element from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 elements and their chemical symbols
element_symbols_dict = {
    'Hydrogen': 'H',
    'Helium': 'He',
    'Lithium': 'Li',
    'Beryllium': 'Be',
    'Boron': 'B',
    'Carbon': 'C',
    'Nitrogen': 'N',
    'Oxygen': 'O',
    'Fluorine': 'F',
    'Neon': 'Ne'
}

# Print the entire dictionary
print("The entire dictionary:", element_symbols_dict)

# Access and print the symbol of the 6th element (Carbon)
sixth_element_symbol = list(element_symbols_dict.values())[5]  # Index 5 for the 6th item
print("\nThe symbol of the 6th element (Carbon):", sixth_element_symbol)

# Update the symbol of the 8th element (Oxygen)
element_symbols_dict['Oxygen'] = 'O2'
print("\nUpdated symbol of the 8th element (Oxygen):", element_symbols_dict['Oxygen'])

# Delete the 9th element (Fluorine) from the dictionary
del element_symbols_dict['Fluorine']
print("\nDictionary after deleting the 9th element (Fluorine):", element_symbols_dict)

# Print the last key-value pair in the dictionary
last_key = list(element_symbols_dict.keys())[-1]
last_value = element_symbols_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

14. continent_countries_dict.py

  1. Create a dictionary of 6 continents and a list of 3 countries for each.

  2. Print the entire dictionary.

  3. Access and print the countries of the 4th continent.

  4. Update the countries of the 5th continent.

  5. Delete the 6th continent from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 6 continents and a list of 3 countries for each
continent_countries_dict = {
    'Africa': ['Nigeria', 'Egypt', 'South Africa'],
    'Asia': ['China', 'India', 'Japan'],
    'Europe': ['Germany', 'France', 'Italy'],
    'North America': ['USA', 'Canada', 'Mexico'],
    'South America': ['Brazil', 'Argentina', 'Colombia'],
    'Australia': ['Australia', 'New Zealand', 'Papua New Guinea']
}

# Print the entire dictionary
print("The entire dictionary:", continent_countries_dict)

# Access and print the countries of the 4th continent (North America)
fourth_continent_countries = continent_countries_dict['North America']
print("\nThe countries of the 4th continent (North America):", fourth_continent_countries)

# Update the countries of the 5th continent (South America)
continent_countries_dict['South America'] = ['Chile', 'Peru', 'Venezuela']
print("\nUpdated countries of the 5th continent (South America):", continent_countries_dict['South America'])

# Delete the 6th continent (Australia) from the dictionary
del continent_countries_dict['Australia']
print("\nDictionary after deleting the 6th continent (Australia):", continent_countries_dict)

# Print the last key-value pair in the dictionary
last_key = list(continent_countries_dict.keys())[-1]
last_value = continent_countries_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

15. animal_habitats_dict.py

  1. Create a dictionary of 8 animals and their natural habitats.

  2. Print the entire dictionary.

  3. Access and print the habitat of the 3rd animal.

  4. Update the habitat of the 5th animal.

  5. Delete the 7th animal from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 8 animals and their natural habitats
animal_habitats_dict = {
    'Lion': 'Savannah',
    'Penguin': 'Antarctica',
    'Kangaroo': 'Australian Outback',
    'Elephant': 'Grasslands',
    'Polar Bear': 'Arctic',
    'Tiger': 'Tropical Rainforest',
    'Panda': 'Bamboo Forests',
    'Whale': 'Ocean'
}

# Print the entire dictionary
print("The entire dictionary:", animal_habitats_dict)

# Access and print the habitat of the 3rd animal (Kangaroo)
third_animal_habitat = list(animal_habitats_dict.values())[2]  # Index 2 for the 3rd item
print("\nThe habitat of the 3rd animal (Kangaroo):", third_animal_habitat)

# Update the habitat of the 5th animal (Polar Bear)
animal_habitats_dict['Polar Bear'] = 'Frozen Tundra'
print("\nUpdated habitat of the 5th animal (Polar Bear):", animal_habitats_dict['Polar Bear'])

# Delete the 7th animal (Panda) from the dictionary
del animal_habitats_dict['Panda']
print("\nDictionary after deleting the 7th animal (Panda):", animal_habitats_dict)

# Print the last key-value pair in the dictionary
last_key = list(animal_habitats_dict.keys())[-1]
last_value = animal_habitats_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

16. company_ceos_dict.py

  1. Create a dictionary of 10 companies and their current CEOs.

  2. Print the entire dictionary.

  3. Access and print the CEO of the 6th company.

  4. Update the CEO of the 3rd company.

  5. Delete the 9th company from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 companies and their current CEOs
company_ceos_dict = {
    'Apple': 'Tim Cook',
    'Microsoft': 'Satya Nadella',
    'Amazon': 'Andy Jassy',
    'Google': 'Sundar Pichai',
    'Facebook': 'Mark Zuckerberg',
    'Tesla': 'Elon Musk',
    'Netflix': 'Reed Hastings',
    'Samsung': 'Kim Hyun Suk',
    'Adobe': 'Shantanu Narayen',
    'Intel': 'Pat Gelsinger'
}

# Print the entire dictionary
print("The entire dictionary:", company_ceos_dict)

# Access and print the CEO of the 6th company (Tesla)
sixth_company_ceo = list(company_ceos_dict.values())[5]  # Index 5 for the 6th item
print("\nThe CEO of the 6th company (Tesla):", sixth_company_ceo)

# Update the CEO of the 3rd company (Amazon)
company_ceos_dict['Amazon'] = 'Jeff Bezos'  # Updating CEO of Amazon
print("\nUpdated CEO of the 3rd company (Amazon):", company_ceos_dict['Amazon'])

# Delete the 9th company (Adobe) from the dictionary
del company_ceos_dict['Adobe']
print("\nDictionary after deleting the 9th company (Adobe):", company_ceos_dict)

# Print the last key-value pair in the dictionary
last_key = list(company_ceos_dict.keys())[-1]
last_value = company_ceos_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

17. space_missions_dict.py

  1. Create a dictionary of 5 space missions and their corresponding years.

  2. Print the entire dictionary.

  3. Access and print the year of the 3rd mission.

  4. Update the year of the 2nd mission.

  5. Delete the 4th mission from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 5 space missions and their corresponding years
space_missions_dict = {
    'Apollo 11': 1969,
    'Mars Rover': 2021,
    'Voyager 1': 1977,
    'Hubble Space Telescope': 1990,
    'International Space Station': 1998
}

# Print the entire dictionary
print("The entire dictionary:", space_missions_dict)

# Access and print the year of the 3rd mission (Voyager 1)
third_mission_year = list(space_missions_dict.values())[2]  # Index 2 for the 3rd item
print("\nThe year of the 3rd mission (Voyager 1):", third_mission_year)

# Update the year of the 2nd mission (Mars Rover)
space_missions_dict['Mars Rover'] = 2020  # Updating the year of the Mars Rover mission
print("\nUpdated year of the 2nd mission (Mars Rover):", space_missions_dict['Mars Rover'])

# Delete the 4th mission (Hubble Space Telescope) from the dictionary
del space_missions_dict['Hubble Space Telescope']
print("\nDictionary after deleting the 4th mission (Hubble Space Telescope):", space_missions_dict)

# Print the last key-value pair in the dictionary
last_key = list(space_missions_dict.keys())[-1]
last_value = space_missions_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

18. flower_meanings_dict.py

  1. Create a dictionary of 8 flowers and their symbolic meanings.

  2. Print the entire dictionary.

  3. Access and print the meaning of the 5th flower.

  4. Update the meaning of the 7th flower.

  5. Delete the 6th flower from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 8 flowers and their symbolic meanings
flower_meanings_dict = {
    'Rose': 'Love and passion',
    'Lily': 'Purity and refined beauty',
    'Tulip': 'Perfect love',
    'Orchid': 'Luxury and strength',
    'Daisy': 'Innocence and purity',
    'Sunflower': 'Adoration and loyalty',
    'Violet': 'Modesty and faithfulness',
    'Chrysanthemum': 'Optimism and joy'
}

# Print the entire dictionary
print("The entire dictionary:", flower_meanings_dict)

# Access and print the meaning of the 5th flower (Daisy)
fifth_flower_meaning = list(flower_meanings_dict.values())[4]  # Index 4 for the 5th item
print("\nThe meaning of the 5th flower (Daisy):", fifth_flower_meaning)

# Update the meaning of the 7th flower (Violet)
flower_meanings_dict['Violet'] = 'Humility and spirituality'  # Updating the meaning of Violet
print("\nUpdated meaning of the 7th flower (Violet):", flower_meanings_dict['Violet'])

# Delete the 6th flower (Sunflower) from the dictionary
del flower_meanings_dict['Sunflower']
print("\nDictionary after deleting the 6th flower (Sunflower):", flower_meanings_dict)

# Print the last key-value pair in the dictionary
last_key = list(flower_meanings_dict.keys())[-1]
last_value = flower_meanings_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

19. holiday_dates_dict.py

  1. Create a dictionary of 10 holidays and their corresponding dates.

  2. Print the entire dictionary.

  3. Access and print the date of the 4th holiday.

  4. Update the date of the 9th holiday.

  5. Delete the 2nd holiday from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 holidays and their corresponding dates
holiday_dates_dict = {
    'New Year\'s Day': 'January 1',
    'Valentine\'s Day': 'February 14',
    'Easter': 'April 9, 2023',
    'Independence Day': 'July 4',
    'Halloween': 'October 31',
    'Thanksgiving': 'November 23, 2023',
    'Christmas': 'December 25',
    'Labor Day': 'First Monday in September',
    'Memorial Day': 'Last Monday in May',
    'Veterans Day': 'November 11'
}

# Print the entire dictionary
print("The entire dictionary:", holiday_dates_dict)

# Access and print the date of the 4th holiday (Independence Day)
fourth_holiday_date = list(holiday_dates_dict.values())[3]  # Index 3 for the 4th item
print("\nThe date of the 4th holiday (Independence Day):", fourth_holiday_date)

# Update the date of the 9th holiday (Memorial Day)
holiday_dates_dict['Memorial Day'] = 'May 29, 2023'  # Updating the date of Memorial Day
print("\nUpdated date of the 9th holiday (Memorial Day):", holiday_dates_dict['Memorial Day'])

# Delete the 2nd holiday (Valentine's Day) from the dictionary
del holiday_dates_dict['Valentine\'s Day']
print("\nDictionary after deleting the 2nd holiday (Valentine's Day):", holiday_dates_dict)

# Print the last key-value pair in the dictionary
last_key = list(holiday_dates_dict.keys())[-1]
last_value = holiday_dates_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

20. river_lengths_dict.py

  1. Create a dictionary of 6 rivers and their lengths in kilometers.

  2. Print the entire dictionary.

  3. Access and print the length of the 2nd river.

  4. Update the length of the 5th river.

  5. Delete the 4th river from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 6 rivers and their lengths in kilometers
river_lengths_dict = {
    'Nile': 6650,
    'Amazon': 6400,
    'Yangtze': 6300,
    'Mississippi': 3730,
    'Ganges': 2525,
    'Danube': 2850
}

# Print the entire dictionary
print("The entire dictionary:", river_lengths_dict)

# Access and print the length of the 2nd river (Amazon)
second_river_length = list(river_lengths_dict.values())[1]  # Index 1 for the 2nd item
print("\nThe length of the 2nd river (Amazon):", second_river_length)

# Update the length of the 5th river (Ganges)
river_lengths_dict['Ganges'] = 2600  # Updating the length of the Ganges river
print("\nUpdated length of the 5th river (Ganges):", river_lengths_dict['Ganges'])

# Delete the 4th river (Mississippi) from the dictionary
del river_lengths_dict['Mississippi']
print("\nDictionary after deleting the 4th river (Mississippi):", river_lengths_dict)

# Print the last key-value pair in the dictionary
last_key = list(river_lengths_dict.keys())[-1]
last_value = river_lengths_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

21. app_store_ratings_dict.py

  1. Create a dictionary of 10 apps and their user ratings.

  2. Print the entire dictionary.

  3. Access and print the rating of the 6th app.

  4. Update the rating of the 8th app.

  5. Delete the 9th app from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 apps and their user ratings
app_store_ratings_dict = {
    'WhatsApp': 4.7,
    'Instagram': 4.6,
    'Facebook': 4.4,
    'Snapchat': 4.3,
    'Twitter': 4.2,
    'TikTok': 4.9,
    'YouTube': 4.8,
    'Spotify': 4.5,
    'Messenger': 4.3,
    'Reddit': 4.1
}

# Print the entire dictionary
print("The entire dictionary:", app_store_ratings_dict)

# Access and print the rating of the 6th app (TikTok)
sixth_app_rating = list(app_store_ratings_dict.values())[5]  # Index 5 for the 6th item
print("\nThe rating of the 6th app (TikTok):", sixth_app_rating)

# Update the rating of the 8th app (Spotify)
app_store_ratings_dict['Spotify'] = 4.7  # Updating the rating of Spotify
print("\nUpdated rating of the 8th app (Spotify):", app_store_ratings_dict['Spotify'])

# Delete the 9th app (Messenger) from the dictionary
del app_store_ratings_dict['Messenger']
print("\nDictionary after deleting the 9th app (Messenger):", app_store_ratings_dict)

# Print the last key-value pair in the dictionary
last_key = list(app_store_ratings_dict.keys())[-1]
last_value = app_store_ratings_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

22. movie_genres_dict.py

  1. Create a dictionary of 8 movie genres and their corresponding example movies.

  2. Print the entire dictionary.

  3. Access and print the example movie of the 3rd genre.

  4. Update the example movie of the 5th genre.

  5. Delete the 7th genre from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 8 movie genres and their corresponding example movies
movie_genres_dict = {
    'Action': 'Mad Max: Fury Road',
    'Comedy': 'The Hangover',
    'Drama': 'The Shawshank Redemption',
    'Horror': 'A Nightmare on Elm Street',
    'Romance': 'The Notebook',
    'Sci-Fi': 'Inception',
    'Animation': 'Toy Story',
    'Thriller': 'Se7en'
}

# Print the entire dictionary
print("The entire dictionary:", movie_genres_dict)

# Access and print the example movie of the 3rd genre (Drama)
third_genre_movie = list(movie_genres_dict.values())[2]  # Index 2 for the 3rd item
print("\nThe example movie of the 3rd genre (Drama):", third_genre_movie)

# Update the example movie of the 5th genre (Romance)
movie_genres_dict['Romance'] = 'Pride and Prejudice'  # Updating the example movie of Romance genre
print("\nUpdated example movie of the 5th genre (Romance):", movie_genres_dict['Romance'])

# Delete the 7th genre (Animation) from the dictionary
del movie_genres_dict['Animation']
print("\nDictionary after deleting the 7th genre (Animation):", movie_genres_dict)

# Print the last key-value pair in the dictionary
last_key = list(movie_genres_dict.keys())[-1]
last_value = movie_genres_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

23. technology_inventors_dict.py

  1. Create a dictionary of 6 technologies and their inventors.

  2. Print the entire dictionary.

  3. Access and print the inventor of the 4th technology.

  4. Update the inventor of the 2nd technology.

  5. Delete the 6th technology from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 6 technologies and their inventors
technology_inventors_dict = {
    'Telephone': 'Alexander Graham Bell',
    'Lightbulb': 'Thomas Edison',
    'Airplane': 'Wright Brothers',
    'Computer': 'Charles Babbage',
    'Internet': 'Tim Berners-Lee',
    'Printing Press': 'Johannes Gutenberg'
}

# Print the entire dictionary
print("The entire dictionary:", technology_inventors_dict)

# Access and print the inventor of the 4th technology (Computer)
fourth_technology_inventor = list(technology_inventors_dict.values())[3]  # Index 3 for the 4th item
print("\nThe inventor of the 4th technology (Computer):", fourth_technology_inventor)

# Update the inventor of the 2nd technology (Lightbulb)
technology_inventors_dict['Lightbulb'] = 'Humphry Davy'  # Updating the inventor of the Lightbulb
print("\nUpdated inventor of the 2nd technology (Lightbulb):", technology_inventors_dict['Lightbulb'])

# Delete the 6th technology (Printing Press) from the dictionary
del technology_inventors_dict['Printing Press']
print("\nDictionary after deleting the 6th technology (Printing Press):", technology_inventors_dict)

# Print the last key-value pair in the dictionary
last_key = list(technology_inventors_dict.keys())[-1]
last_value = technology_inventors_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

24. currency_symbols_dict.py

  1. Create a dictionary of 10 currencies and their symbols.

  2. Print the entire dictionary.

  3. Access and print the symbol of the 5th currency.

  4. Update the symbol of the 9th currency.

  5. Delete the 3rd currency from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 currencies and their symbols
currency_symbols_dict = {
    'USD': '$',
    'EUR': '€',
    'GBP': '£',
    'JPY': '¥',
    'AUD': '$',
    'CAD': '$',
    'CHF': 'Fr.',
    'INR': '₹',
    'CNY': '¥',
    'MXN': '$'
}

# Print the entire dictionary
print("The entire dictionary:", currency_symbols_dict)

# Access and print the symbol of the 5th currency (AUD)
fifth_currency_symbol = list(currency_symbols_dict.values())[4]  # Index 4 for the 5th item
print("\nThe symbol of the 5th currency (AUD):", fifth_currency_symbol)

# Update the symbol of the 9th currency (CNY)
currency_symbols_dict['CNY'] = '元'  # Updating the symbol of the CNY currency
print("\nUpdated symbol of the 9th currency (CNY):", currency_symbols_dict['CNY'])

# Delete the 3rd currency (GBP) from the dictionary
del currency_symbols_dict['GBP']
print("\nDictionary after deleting the 3rd currency (GBP):", currency_symbols_dict)

# Print the last key-value pair in the dictionary
last_key = list(currency_symbols_dict.keys())[-1]
last_value = currency_symbols_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

25. video_game_platforms_dict.py

  1. Create a dictionary of 8 video games and their platforms.

  2. Print the entire dictionary.

  3. Access and print the platform of the 2nd video game.

  4. Update the platform of the 6th video game.

  5. Delete the 4th video game from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 8 video games and their platforms
video_game_platforms_dict = {
    'The Last of Us': 'PlayStation 3, PlayStation 4',
    'Minecraft': 'PC, Xbox, PlayStation, Switch',
    'Fortnite': 'PC, Xbox, PlayStation, Switch',
    'Call of Duty: Warzone': 'PC, Xbox, PlayStation',
    'Red Dead Redemption 2': 'PC, Xbox, PlayStation',
    'Cyberpunk 2077': 'PC, Xbox, PlayStation',
    'Super Mario Odyssey': 'Switch',
    'The Witcher 3: Wild Hunt': 'PC, Xbox, PlayStation, Switch'
}

# Print the entire dictionary
print("The entire dictionary:", video_game_platforms_dict)

# Access and print the platform of the 2nd video game (Minecraft)
second_game_platform = list(video_game_platforms_dict.values())[1]  # Index 1 for the 2nd item
print("\nThe platform of the 2nd video game (Minecraft):", second_game_platform)

# Update the platform of the 6th video game (Cyberpunk 2077)
video_game_platforms_dict['Cyberpunk 2077'] = 'PC, Xbox, PlayStation, Stadia'  # Updating the platform of Cyberpunk 2077
print("\nUpdated platform of the 6th video game (Cyberpunk 2077):", video_game_platforms_dict['Cyberpunk 2077'])

# Delete the 4th video game (Call of Duty: Warzone) from the dictionary
del video_game_platforms_dict['Call of Duty: Warzone']
print("\nDictionary after deleting the 4th video game (Call of Duty: Warzone):", video_game_platforms_dict)

# Print the last key-value pair in the dictionary
last_key = list(video_game_platforms_dict.keys())[-1]
last_value = video_game_platforms_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

26. planet_distances_dict.py

  1. Create a dictionary of 8 planets and their distances from the sun (in million kilometers).

  2. Print the entire dictionary.

  3. Access and print the distance of the 3rd planet.

  4. Update the distance of the 5th planet.

  5. Delete the 7th planet from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 8 planets and their distances from the Sun (in million kilometers)
planet_distances_dict = {
    'Mercury': 57.9,
    'Venus': 108.2,
    'Earth': 149.6,
    'Mars': 227.9,
    'Jupiter': 778.3,
    'Saturn': 1427.0,
    'Uranus': 2871.0,
    'Neptune': 4497.1
}

# Print the entire dictionary
print("The entire dictionary:", planet_distances_dict)

# Access and print the distance of the 3rd planet (Earth)
third_planet_distance = list(planet_distances_dict.values())[2]  # Index 2 for the 3rd planet
print("\nThe distance of the 3rd planet (Earth):", third_planet_distance, "million kilometers")

# Update the distance of the 5th planet (Jupiter)
planet_distances_dict['Jupiter'] = 800.0  # Updating the distance of Jupiter
print("\nUpdated distance of the 5th planet (Jupiter):", planet_distances_dict['Jupiter'], "million kilometers")

# Delete the 7th planet (Uranus) from the dictionary
del planet_distances_dict['Uranus']
print("\nDictionary after deleting the 7th planet (Uranus):", planet_distances_dict)

# Print the last key-value pair in the dictionary
last_key = list(planet_distances_dict.keys())[-1]
last_value = planet_distances_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

27. product_prices_dict.py

  1. Create a dictionary of 10 products and their prices.

  2. Print the entire dictionary.

  3. Access and print the price of the 4th product.

  4. Update the price of the 9th product.

  5. Delete the 6th product from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 products and their prices
product_prices_dict = {
    'Laptop': 999.99,
    'Smartphone': 799.99,
    'Headphones': 199.99,
    'Keyboard': 49.99,
    'Mouse': 29.99,
    'Monitor': 159.99,
    'USB Drive': 19.99,
    'Webcam': 79.99,
    'Smartwatch': 249.99,
    'Speaker': 89.99
}

# Print the entire dictionary
print("The entire dictionary:", product_prices_dict)

# Access and print the price of the 4th product (Keyboard)
fourth_product_price = list(product_prices_dict.values())[3]  # Index 3 for the 4th product
print("\nThe price of the 4th product (Keyboard):", fourth_product_price)

# Update the price of the 9th product (Smartwatch)
product_prices_dict['Smartwatch'] = 259.99  # Updating the price of Smartwatch
print("\nUpdated price of the 9th product (Smartwatch):", product_prices_dict['Smartwatch'])

# Delete the 6th product (Monitor) from the dictionary
del product_prices_dict['Monitor']
print("\nDictionary after deleting the 6th product (Monitor):", product_prices_dict)

# Print the last key-value pair in the dictionary
last_key = list(product_prices_dict.keys())[-1]
last_value = product_prices_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

28. athlete_achievements_dict.py

  1. Create a dictionary of 8 athletes and their greatest achievements.

  2. Print the entire dictionary.

  3. Access and print the achievement of the 5th athlete.

  4. Update the achievement of the 3rd athlete.

  5. Delete the 7th athlete from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 8 athletes and their greatest achievements
athlete_achievements_dict = {
    'Usain Bolt': 'World record in 100m and 200m sprints',
    'Michael Phelps': 'Winning 23 Olympic gold medals',
    'Serena Williams': '23 Grand Slam singles titles',
    'Cristiano Ronaldo': '5 Ballon d\'Or awards',
    'Simone Biles': '4 Olympic gold medals in gymnastics',
    'LeBron James': '4 NBA championships',
    'Roger Federer': '20 Grand Slam singles titles',
    'Tom Brady': '7 Super Bowl championships'
}

# Print the entire dictionary
print("The entire dictionary:", athlete_achievements_dict)

# Access and print the achievement of the 5th athlete (Simone Biles)
fifth_athlete_achievement = list(athlete_achievements_dict.values())[4]  # Index 4 for the 5th athlete
print("\nThe achievement of the 5th athlete (Simone Biles):", fifth_athlete_achievement)

# Update the achievement of the 3rd athlete (Serena Williams)
athlete_achievements_dict['Serena Williams'] = 'Most Grand Slam singles titles in the Open Era (23 titles)'  # Updating the achievement
print("\nUpdated achievement of the 3rd athlete (Serena Williams):", athlete_achievements_dict['Serena Williams'])

# Delete the 7th athlete (Roger Federer) from the dictionary
del athlete_achievements_dict['Roger Federer']
print("\nDictionary after deleting the 7th athlete (Roger Federer):", athlete_achievements_dict)

# Print the last key-value pair in the dictionary
last_key = list(athlete_achievements_dict.keys())[-1]
last_value = athlete_achievements_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

29. phone_models_dict.py

  1. Create a dictionary of 10 phone models and their manufacturers.

  2. Print the entire dictionary.

  3. Access and print the manufacturer of the 2nd phone model.

  4. Update the manufacturer of the 8th phone model.

  5. Delete the 6th phone model from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 phone models and their manufacturers
phone_models_dict = {
    'iPhone 15': 'Apple',
    'Galaxy S23': 'Samsung',
    'Pixel 8': 'Google',
    'OnePlus 11': 'OnePlus',
    'Xperia 1 IV': 'Sony',
    'Moto G Power': 'Motorola',
    'Redmi Note 12': 'Xiaomi',
    'Galaxy Z Fold 5': 'Samsung',
    'Nokia G400': 'Nokia',
    'Huawei P60': 'Huawei'
}

# Print the entire dictionary
print("The entire dictionary:", phone_models_dict)

# Access and print the manufacturer of the 2nd phone model (Galaxy S23)
second_phone_manufacturer = list(phone_models_dict.values())[1]  # Index 1 for the 2nd phone model
print("\nThe manufacturer of the 2nd phone model (Galaxy S23):", second_phone_manufacturer)

# Update the manufacturer of the 8th phone model (Galaxy Z Fold 5)
phone_models_dict['Galaxy Z Fold 5'] = 'Samsung Electronics'  # Updating the manufacturer
print("\nUpdated manufacturer of the 8th phone model (Galaxy Z Fold 5):", phone_models_dict['Galaxy Z Fold 5'])

# Delete the 6th phone model (Moto G Power) from the dictionary
del phone_models_dict['Moto G Power']
print("\nDictionary after deleting the 6th phone model (Moto G Power):", phone_models_dict)

# Print the last key-value pair in the dictionary
last_key = list(phone_models_dict.keys())[-1]
last_value = phone_models_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

30. software_versions_dict.py

  1. Create a dictionary of 6 software programs and their latest versions.

  2. Print the entire dictionary.

  3. Access and print the version of the 4th software.

  4. Update the version of the 2nd software.

  5. Delete the 5th software from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 6 software programs and their latest versions
software_versions_dict = {
    'Windows 11': '22H2',
    'macOS Ventura': '13.3',
    'Ubuntu': '23.04',
    'Chrome': '117.0.5938.92',
    'Firefox': '118.0.1',
    'Slack': '4.29.2'
}

# Print the entire dictionary
print("The entire dictionary:", software_versions_dict)

# Access and print the version of the 4th software (Chrome)
fourth_software_version = list(software_versions_dict.values())[3]  # Index 3 for the 4th software
print("\nThe version of the 4th software (Chrome):", fourth_software_version)

# Update the version of the 2nd software (macOS Ventura)
software_versions_dict['macOS Ventura'] = '13.4'  # Updating the version
print("\nUpdated version of the 2nd software (macOS Ventura):", software_versions_dict['macOS Ventura'])

# Delete the 5th software (Firefox) from the dictionary
del software_versions_dict['Firefox']
print("\nDictionary after deleting the 5th software (Firefox):", software_versions_dict)

# Print the last key-value pair in the dictionary
last_key = list(software_versions_dict.keys())[-1]
last_value = software_versions_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

31. festival_dates_dict.py

  1. Create a dictionary of 10 festivals and their celebration dates.

  2. Print the entire dictionary.

  3. Access and print the date of the 3rd festival.

  4. Update the date of the 7th festival.

  5. Delete the 5th festival from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 festivals and their celebration dates
festival_dates_dict = {
    'Diwali': 'November 12, 2023',
    'Christmas': 'December 25, 2023',
    'Easter': 'April 9, 2023',
    'Halloween': 'October 31, 2023',
    'Thanksgiving': 'November 23, 2023',
    'New Year': 'January 1, 2024',
    'Lunar New Year': 'February 10, 2024',
    'Holi': 'March 25, 2024',
    'Ramadan': 'March 11, 2024',
    'Oktoberfest': 'September 21, 2024'
}

# Print the entire dictionary
print("The entire dictionary:", festival_dates_dict)

# Access and print the date of the 3rd festival (Easter)
third_festival_date = list(festival_dates_dict.values())[2]  # Index 2 for the 3rd festival
print("\nThe date of the 3rd festival (Easter):", third_festival_date)

# Update the date of the 7th festival (Lunar New Year)
festival_dates_dict['Lunar New Year'] = 'February 14, 2024'  # Updating the date
print("\nUpdated date of the 7th festival (Lunar New Year):", festival_dates_dict['Lunar New Year'])

# Delete the 5th festival (Thanksgiving) from the dictionary
del festival_dates_dict['Thanksgiving']
print("\nDictionary after deleting the 5th festival (Thanksgiving):", festival_dates_dict)

# Print the last key-value pair in the dictionary
last_key = list(festival_dates_dict.keys())[-1]
last_value = festival_dates_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

32. company_founders_dict.py

  1. Create a dictionary of 8 companies and their founders.

  2. Print the entire dictionary.

  3. Access and print the founder of the 6th company.

  4. Update the founder of the 2nd company.

  5. Delete the 8th company from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 8 companies and their founders
company_founders_dict = {
    'Apple': 'Steve Jobs',
    'Microsoft': 'Bill Gates',
    'Tesla': 'Elon Musk',
    'Amazon': 'Jeff Bezos',
    'Facebook': 'Mark Zuckerberg',
    'Google': 'Larry Page and Sergey Brin',
    'Twitter': 'Jack Dorsey',
    'SpaceX': 'Elon Musk'
}

# Print the entire dictionary
print("The entire dictionary:", company_founders_dict)

# Access and print the founder of the 6th company (Google)
sixth_company_founder = list(company_founders_dict.values())[5]  # Index 5 for the 6th company
print("\nThe founder of the 6th company (Google):", sixth_company_founder)

# Update the founder of the 2nd company (Microsoft)
company_founders_dict['Microsoft'] = 'Paul Allen'  # Updating the founder
print("\nUpdated founder of the 2nd company (Microsoft):", company_founders_dict['Microsoft'])

# Delete the 8th company (SpaceX) from the dictionary
del company_founders_dict['SpaceX']
print("\nDictionary after deleting the 8th company (SpaceX):", company_founders_dict)

# Print the last key-value pair in the dictionary
last_key = list(company_founders_dict.keys())[-1]
last_value = company_founders_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

33. car_specs_dict.py

  1. Create a dictionary of 10 car models and their engine specifications.

  2. Print the entire dictionary.

  3. Access and print the specifications of the 4th car model.

  4. Update the specifications of the 9th car model.

  5. Delete the 5th car model from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 car models and their engine specifications
car_specs_dict = {
    'Toyota Corolla': '1.8L 4-Cylinder, 139 hp',
    'Honda Civic': '2.0L 4-Cylinder, 158 hp',
    'Ford Mustang': '5.0L V8, 450 hp',
    'Chevrolet Camaro': '6.2L V8, 455 hp',
    'BMW 3 Series': '2.0L 4-Cylinder Turbo, 255 hp',
    'Audi A4': '2.0L 4-Cylinder Turbo, 188 hp',
    'Mercedes-Benz C-Class': '2.0L 4-Cylinder Turbo, 255 hp',
    'Tesla Model 3': 'Electric, 283 hp',
    'Nissan Altima': '2.5L 4-Cylinder, 188 hp',
    'Volkswagen Jetta': '1.4L 4-Cylinder Turbo, 147 hp'
}

# Print the entire dictionary
print("The entire dictionary:", car_specs_dict)

# Access and print the specifications of the 4th car model (Chevrolet Camaro)
fourth_car_specs = list(car_specs_dict.values())[3]  # Index 3 for the 4th car model
print("\nThe specifications of the 4th car model (Chevrolet Camaro):", fourth_car_specs)

# Update the specifications of the 9th car model (Nissan Altima)
car_specs_dict['Nissan Altima'] = '2.5L 4-Cylinder, 190 hp'  # Updating the specifications
print("\nUpdated specifications of the 9th car model (Nissan Altima):", car_specs_dict['Nissan Altima'])

# Delete the 5th car model (BMW 3 Series) from the dictionary
del car_specs_dict['BMW 3 Series']
print("\nDictionary after deleting the 5th car model (BMW 3 Series):", car_specs_dict)

# Print the last key-value pair in the dictionary
last_key = list(car_specs_dict.keys())[-1]
last_value = car_specs_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

34. artist_songs_dict.py

  1. Create a dictionary of 8 artists and their top songs.

  2. Print the entire dictionary.

  3. Access and print the top song of the 3rd artist.

  4. Update the top song of the 6th artist.

  5. Delete the 7th artist from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 8 artists and their top songs
artist_songs_dict = {
    'Taylor Swift': 'Shake It Off',
    'Ed Sheeran': 'Shape of You',
    'Adele': 'Hello',
    'Drake': 'God\'s Plan',
    'Billie Eilish': 'Bad Guy',
    'The Weeknd': 'Blinding Lights',
    'Bruno Mars': 'Uptown Funk',
    'Post Malone': 'Circles'
}

# Print the entire dictionary
print("The entire dictionary:", artist_songs_dict)

# Access and print the top song of the 3rd artist (Adele)
third_artist_song = list(artist_songs_dict.values())[2]  # Index 2 for the 3rd artist
print("\nThe top song of the 3rd artist (Adele):", third_artist_song)

# Update the top song of the 6th artist (The Weeknd)
artist_songs_dict['The Weeknd'] = 'Save Your Tears'  # Updating the top song
print("\nUpdated top song of the 6th artist (The Weeknd):", artist_songs_dict['The Weeknd'])

# Delete the 7th artist (Bruno Mars) from the dictionary
del artist_songs_dict['Bruno Mars']
print("\nDictionary after deleting the 7th artist (Bruno Mars):", artist_songs_dict)

# Print the last key-value pair in the dictionary
last_key = list(artist_songs_dict.keys())[-1]
last_value = artist_songs_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

35. dog_breeds_dict.py

  1. Create a dictionary of 10 dog breeds and their sizes (small, medium, large).

  2. Print the entire dictionary.

  3. Access and print the size of the 5th breed.

  4. Update the size of the 8th breed.

  5. Delete the 6th breed from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 dog breeds and their sizes
dog_breeds_dict = {
    'Chihuahua': 'Small',
    'Beagle': 'Medium',
    'Labrador Retriever': 'Large',
    'German Shepherd': 'Large',
    'Bulldog': 'Medium',
    'Poodle': 'Medium',
    'Golden Retriever': 'Large',
    'Cocker Spaniel': 'Medium',
    'Boxer': 'Large',
    'Dachshund': 'Small'
}

# Print the entire dictionary
print("The entire dictionary:", dog_breeds_dict)

# Access and print the size of the 5th breed (Bulldog)
fifth_breed_size = list(dog_breeds_dict.values())[4]  # Index 4 for the 5th breed
print("\nThe size of the 5th breed (Bulldog):", fifth_breed_size)

# Update the size of the 8th breed (Cocker Spaniel)
dog_breeds_dict['Cocker Spaniel'] = 'Small'  # Updating the size
print("\nUpdated size of the 8th breed (Cocker Spaniel):", dog_breeds_dict['Cocker Spaniel'])

# Delete the 6th breed (Poodle) from the dictionary
del dog_breeds_dict['Poodle']
print("\nDictionary after deleting the 6th breed (Poodle):", dog_breeds_dict)

# Print the last key-value pair in the dictionary
last_key = list(dog_breeds_dict.keys())[-1]
last_value = dog_breeds_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

36. historical_events_dict.py

  1. Create a dictionary of 8 historical events and their years.

  2. Print the entire dictionary.

  3. Access and print the year of the 2nd event.

  4. Update the year of the 7th event.

  5. Delete the 5th event from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 8 historical events and their years
historical_events_dict = {
    'The Declaration of Independence': 1776,
    'The French Revolution': 1789,
    'World War I Begins': 1914,
    'World War II Begins': 1939,
    'The Moon Landing': 1969,
    'Fall of the Berlin Wall': 1989,
    'The September 11 Attacks': 2001,
    'The End of Apartheid in South Africa': 1994
}

# Print the entire dictionary
print("The entire dictionary:", historical_events_dict)

# Access and print the year of the 2nd event (The French Revolution)
second_event_year = list(historical_events_dict.values())[1]  # Index 1 for the 2nd event
print("\nThe year of the 2nd event (The French Revolution):", second_event_year)

# Update the year of the 7th event (The September 11 Attacks)
historical_events_dict['The September 11 Attacks'] = 2002  # Updating the year
print("\nUpdated year of the 7th event (The September 11 Attacks):", historical_events_dict['The September 11 Attacks'])

# Delete the 5th event (The Moon Landing) from the dictionary
del historical_events_dict['The Moon Landing']
print("\nDictionary after deleting the 5th event (The Moon Landing):", historical_events_dict)

# Print the last key-value pair in the dictionary
last_key = list(historical_events_dict.keys())[-1]
last_value = historical_events_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

37. state_capitals_dict.py

  1. Create a dictionary of 10 states and their capitals.

  2. Print the entire dictionary.

  3. Access and print the capital of the 4th state.

  4. Update the capital of the 9th state.

  5. Delete the 7th state from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 states and their capitals
state_capitals_dict = {
    'California': 'Sacramento',
    'Texas': 'Austin',
    'Florida': 'Tallahassee',
    'New York': 'Albany',
    'Illinois': 'Springfield',
    'Pennsylvania': 'Harrisburg',
    'Ohio': 'Columbus',
    'Georgia': 'Atlanta',
    'North Carolina': 'Raleigh',
    'Michigan': 'Lansing'
}

# Print the entire dictionary
print("The entire dictionary:", state_capitals_dict)

# Access and print the capital of the 4th state (New York)
fourth_state_capital = list(state_capitals_dict.values())[3]  # Index 3 for the 4th state
print("\nThe capital of the 4th state (New York):", fourth_state_capital)

# Update the capital of the 9th state (North Carolina)
state_capitals_dict['North Carolina'] = 'Charlotte'  # Updating the capital
print("\nUpdated capital of the 9th state (North Carolina):", state_capitals_dict['North Carolina'])

# Delete the 7th state (Ohio) from the dictionary
del state_capitals_dict['Ohio']
print("\nDictionary after deleting the 7th state (Ohio):", state_capitals_dict)

# Print the last key-value pair in the dictionary
last_key = list(state_capitals_dict.keys())[-1]
last_value = state_capitals_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

38. plant_types_dict.py

  1. Create a dictionary of 8 plants and their types (e.g., shrub, tree, herb).

  2. Print the entire dictionary.

  3. Access and print the type of the 5th plant.

  4. Update the type of the 2nd plant.

  5. Delete the 6th plant from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 8 plants and their types
plant_types_dict = {
    'Rose': 'Shrub',
    'Oak': 'Tree',
    'Basil': 'Herb',
    'Cactus': 'Succulent',
    'Tulip': 'Flowering Plant',
    'Fern': 'Fern',
    'Lavender': 'Herb',
    'Pine': 'Tree'
}

# Print the entire dictionary
print("The entire dictionary:", plant_types_dict)

# Access and print the type of the 5th plant (Tulip)
fifth_plant_type = list(plant_types_dict.values())[4]  # Index 4 for the 5th plant
print("\nThe type of the 5th plant (Tulip):", fifth_plant_type)

# Update the type of the 2nd plant (Oak)
plant_types_dict['Oak'] = 'Deciduous Tree'  # Updating the type
print("\nUpdated type of the 2nd plant (Oak):", plant_types_dict['Oak'])

# Delete the 6th plant (Fern) from the dictionary
del plant_types_dict['Fern']
print("\nDictionary after deleting the 6th plant (Fern):", plant_types_dict)

# Print the last key-value pair in the dictionary
last_key = list(plant_types_dict.keys())[-1]
last_value = plant_types_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

39. music_albums_dict.py

  1. Create a dictionary of 10 music albums and their release years.

  2. Print the entire dictionary.

  3. Access and print the release year of the 3rd album.

  4. Update the release year of the 8th album.

  5. Delete the 5th album from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 music albums and their release years (2018 to 2024)
music_albums_dict = {
    'Future Nostalgia': 2020,
    'Lover': 2019,
    'After Hours': 2020,
    'Folklore': 2020,
    'Scorpion': 2018,
    'Fine Line': 2019,
    'What’s Your Pleasure?': 2020,
    'Chromatica': 2020,
    'Positions': 2020,
    'Fearless (Taylor’s Version)': 2021
}

# Print the entire dictionary
print("The entire dictionary:", music_albums_dict)

# Access and print the release year of the 3rd album (After Hours)
third_album_year = list(music_albums_dict.values())[2]  # Index 2 for the 3rd album
print("\nThe release year of the 3rd album (After Hours):", third_album_year)

# Update the release year of the 8th album (Chromatica)
music_albums_dict['Chromatica'] = 2021  # Updating the release year
print("\nUpdated release year of the 8th album (Chromatica):", music_albums_dict['Chromatica'])

# Delete the 5th album (Scorpion) from the dictionary
del music_albums_dict['Scorpion']
print("\nDictionary after deleting the 5th album (Scorpion):", music_albums_dict)

# Print the last key-value pair in the dictionary
last_key = list(music_albums_dict.keys())[-1]
last_value = music_albums_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

40. city_landmarks_dict.py

  1. Create a dictionary of 8 cities and their famous landmarks.

  2. Print the entire dictionary.

  3. Access and print the landmark of the 6th city.

  4. Update the landmark of the 2nd city.

  5. Delete the 7th city from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 8 cities and their famous landmarks
city_landmarks_dict = {
    'Paris': 'Eiffel Tower',
    'New York': 'Statue of Liberty',
    'Rome': 'Colosseum',
    'London': 'Big Ben',
    'Tokyo': 'Tokyo Tower',
    'Cairo': 'Pyramids of Giza',
    'Sydney': 'Sydney Opera House',
    'Beijing': 'Great Wall of China'
}

# Print the entire dictionary
print("The entire dictionary:", city_landmarks_dict)

# Access and print the landmark of the 6th city (Cairo)
sixth_city_landmark = list(city_landmarks_dict.values())[5]  # Index 5 for the 6th city
print("\nThe landmark of the 6th city (Cairo):", sixth_city_landmark)

# Update the landmark of the 2nd city (New York)
city_landmarks_dict['New York'] = 'Empire State Building'  # Updating the landmark
print("\nUpdated landmark of the 2nd city (New York):", city_landmarks_dict['New York'])

# Delete the 7th city (Sydney) from the dictionary
del city_landmarks_dict['Sydney']
print("\nDictionary after deleting the 7th city (Sydney):", city_landmarks_dict)

# Print the last key-value pair in the dictionary
last_key = list(city_landmarks_dict.keys())[-1]
last_value = city_landmarks_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

41. space_telescope_missions_dict.py

  1. Create a dictionary of 5 space telescopes and their missions.

  2. Print the entire dictionary.

  3. Access and print the mission of the 3rd telescope.

  4. Update the mission of the 1st telescope.

  5. Delete the 4th telescope from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 5 space telescopes and their missions
space_telescope_missions_dict = {
    'Hubble Space Telescope': 'Hubble Deep Field',
    'James Webb Space Telescope': 'First Light',
    'Chandra X-ray Observatory': 'Deep Field Survey',
    'Spitzer Space Telescope': 'Exoplanet Exploration',
    'Kepler Space Telescope': 'Kepler Planet Search'
}

# Print the entire dictionary
print("The entire dictionary:", space_telescope_missions_dict)

# Access and print the mission of the 3rd telescope (Chandra X-ray Observatory)
third_telescope_mission = list(space_telescope_missions_dict.values())[2]  # Index 2 for the 3rd telescope
print("\nThe mission of the 3rd telescope (Chandra X-ray Observatory):", third_telescope_mission)

# Update the mission of the 1st telescope (Hubble Space Telescope)
space_telescope_missions_dict['Hubble Space Telescope'] = 'Hubble Ultra Deep Field'  # Updating the mission
print("\nUpdated mission of the 1st telescope (Hubble Space Telescope):", space_telescope_missions_dict['Hubble Space Telescope'])

# Delete the 4th telescope (Spitzer Space Telescope) from the dictionary
del space_telescope_missions_dict['Spitzer Space Telescope']
print("\nDictionary after deleting the 4th telescope (Spitzer Space Telescope):", space_telescope_missions_dict)

# Print the last key-value pair in the dictionary
last_key = list(space_telescope_missions_dict.keys())[-1]
last_value = space_telescope_missions_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

42. dinosaur_fossils_dict.py

  1. Create a dictionary of 7 dinosaurs and where their fossils were found.

  2. Print the entire dictionary.

  3. Access and print the location of the 4th dinosaur's fossils.

  4. Update the location of the 2nd dinosaur's fossils.

  5. Delete the 6th dinosaur from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 7 dinosaurs and where their fossils were found
dinosaur_fossils_dict = {
    'Tyrannosaurus Rex': 'North America',
    'Velociraptor': 'Mongolia',
    'Triceratops': 'North America',
    'Brachiosaurus': 'Africa',
    'Stegosaurus': 'North America',
    'Allosaurus': 'North America',
    'Spinosaurus': 'North Africa'
}

# Print the entire dictionary
print("The entire dictionary:", dinosaur_fossils_dict)

# Access and print the location of the 4th dinosaur's fossils (Brachiosaurus)
fourth_dinosaur_location = list(dinosaur_fossils_dict.values())[3]  # Index 3 for the 4th dinosaur
print("\nThe location of the 4th dinosaur's fossils (Brachiosaurus):", fourth_dinosaur_location)

# Update the location of the 2nd dinosaur's fossils (Velociraptor)
dinosaur_fossils_dict['Velociraptor'] = 'China'  # Updating the location
print("\nUpdated location of the 2nd dinosaur's fossils (Velociraptor):", dinosaur_fossils_dict['Velociraptor'])

# Delete the 6th dinosaur (Allosaurus) from the dictionary
del dinosaur_fossils_dict['Allosaurus']
print("\nDictionary after deleting the 6th dinosaur (Allosaurus):", dinosaur_fossils_dict)

# Print the last key-value pair in the dictionary
last_key = list(dinosaur_fossils_dict.keys())[-1]
last_value = dinosaur_fossils_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

43. author_books_dict.py

  1. Create a dictionary of 8 authors and their famous books.

  2. Print the entire dictionary.

  3. Access and print the book of the 5th author.

  4. Update the book of the 7th author.

  5. Delete the 6th author from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 8 authors and their famous books
author_books_dict = {
    'J.K. Rowling': 'Harry Potter and the Sorcerer\'s Stone',
    'George Orwell': '1984',
    'J.R.R. Tolkien': 'The Lord of the Rings',
    'Agatha Christie': 'Murder on the Orient Express',
    'F. Scott Fitzgerald': 'The Great Gatsby',
    'Harper Lee': 'To Kill a Mockingbird',
    'Jane Austen': 'Pride and Prejudice',
    'Mark Twain': 'Adventures of Huckleberry Finn'
}

# Print the entire dictionary
print("The entire dictionary:", author_books_dict)

# Access and print the book of the 5th author (F. Scott Fitzgerald)
fifth_author_book = list(author_books_dict.values())[4]  # Index 4 for the 5th author
print("\nThe book of the 5th author (F. Scott Fitzgerald):", fifth_author_book)

# Update the book of the 7th author (Jane Austen)
author_books_dict['Jane Austen'] = 'Sense and Sensibility'  # Updating the book
print("\nUpdated book of the 7th author (Jane Austen):", author_books_dict['Jane Austen'])

# Delete the 6th author (Harper Lee) from the dictionary
del author_books_dict['Harper Lee']
print("\nDictionary after deleting the 6th author (Harper Lee):", author_books_dict)

# Print the last key-value pair in the dictionary
last_key = list(author_books_dict.keys())[-1]
last_value = author_books_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

44. coffee_types_dict.py

  1. Create a dictionary of 10 types of coffee and their descriptions.

  2. Print the entire dictionary.

  3. Access and print the description of the 4th type of coffee.

  4. Update the description of the 8th type of coffee.

  5. Delete the 5th type of coffee from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 types of coffee and their descriptions
coffee_types_dict = {
    'Espresso': 'A strong, black coffee brewed by forcing hot water through finely-ground coffee beans.',
    'Americano': 'A diluted espresso, made by adding hot water to espresso, resulting in a less intense flavor.',
    'Latte': 'A coffee drink made with espresso and steamed milk, topped with a small amount of foam.',
    'Cappuccino': 'A coffee drink made with equal parts espresso, steamed milk, and milk foam.',
    'Macchiato': 'An espresso with a small amount of steamed milk, leaving a "stain" or "mark" on the coffee.',
    'Mocha': 'A coffee drink made with espresso, steamed milk, and chocolate syrup or cocoa powder.',
    'Flat White': 'A coffee drink made with espresso and steamed milk, similar to a latte but with a higher ratio of coffee to milk.',
    'Affogato': 'A dessert coffee made by pouring hot espresso over a scoop of vanilla ice cream.',
    'Cortado': 'A coffee drink made with equal parts espresso and warm milk, typically served in a small glass.',
    'Irish Coffee': 'A cocktail made with hot coffee, Irish whiskey, sugar, and topped with cream.'
}

# Print the entire dictionary
print("The entire dictionary:", coffee_types_dict)

# Access and print the description of the 4th type of coffee (Cappuccino)
fourth_coffee_description = list(coffee_types_dict.values())[3]  # Index 3 for the 4th type
print("\nDescription of the 4th type of coffee (Cappuccino):", fourth_coffee_description)

# Update the description of the 8th type of coffee (Affogato)
coffee_types_dict['Affogato'] = 'A dessert made by pouring hot espresso over a scoop of ice cream or gelato.'
print("\nUpdated description of the 8th type of coffee (Affogato):", coffee_types_dict['Affogato'])

# Delete the 5th type of coffee (Macchiato) from the dictionary
del coffee_types_dict['Macchiato']
print("\nDictionary after deleting the 5th type of coffee (Macchiato):", coffee_types_dict)

# Print the last key-value pair in the dictionary
last_key = list(coffee_types_dict.keys())[-1]
last_value = coffee_types_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

45. job_salaries_dict.py

  1. Create a dictionary of 10 jobs and their average salaries.

  2. Print the entire dictionary.

  3. Access and print the salary of the 3rd job.

  4. Update the salary of the 7th job.

  5. Delete the 9th job from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Creating a dictionary of 10 jobs and their average salaries
job_salaries_dict = {
    'Software Engineer': 100000,
    'Data Scientist': 95000,
    'Product Manager': 120000,
    'Graphic Designer': 55000,
    'Accountant': 65000,
    'Teacher': 45000,
    'Nurse': 75000,
    'Web Developer': 85000,
    'Project Manager': 105000,
    'Chef': 40000
}

# Print the entire dictionary
print("The entire dictionary:", job_salaries_dict)

# Access and print the salary of the 3rd job (Product Manager)
third_job_salary = list(job_salaries_dict.values())[2]  # Index 2 for the 3rd job
print("\nSalary of the 3rd job (Product Manager):", third_job_salary)

# Update the salary of the 7th job (Nurse)
job_salaries_dict['Nurse'] = 80000
print("\nUpdated salary of the 7th job (Nurse):", job_salaries_dict['Nurse'])

# Delete the 9th job (Project Manager) from the dictionary
del job_salaries_dict['Project Manager']
print("\nDictionary after deleting the 9th job (Project Manager):", job_salaries_dict)

# Print the last key-value pair in the dictionary
last_key = list(job_salaries_dict.keys())[-1]
last_value = job_salaries_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

46. food_recipes_dict.py

  1. Create a dictionary of 8 foods and their recipes.

  2. Print the entire dictionary.

  3. Access and print the recipe of the 5th food.

  4. Update the recipe of the 3rd food.

  5. Delete the 7th food from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Create a dictionary of 8 foods and their recipes
food_recipes_dict = {
    'Pizza': 'Dough, tomato sauce, cheese, toppings of your choice',
    'Pasta': 'Pasta, olive oil, garlic, tomatoes, basil, parmesan',
    'Burger': 'Beef patty, lettuce, tomato, cheese, burger bun',
    'Sushi': 'Rice, nori (seaweed), fish, wasabi, soy sauce',
    'Tacos': 'Taco shells, ground beef, lettuce, cheese, salsa, sour cream',
    'Salad': 'Lettuce, tomatoes, cucumber, olive oil, vinegar',
    'Fried Rice': 'Rice, eggs, soy sauce, peas, carrots, onions',
    'Pancakes': 'Flour, eggs, milk, sugar, butter, syrup'
}

# Print the entire dictionary
print("The entire dictionary:")
print(food_recipes_dict)

# Access and print the recipe of the 5th food (Tacos)
fifth_food_recipe = list(food_recipes_dict.values())[4]  # Index 4 for the 5th food
print("\nRecipe of the 5th food (Tacos):", fifth_food_recipe)

# Update the recipe of the 3rd food (Burger)
food_recipes_dict['Burger'] = 'Beef patty, lettuce, tomato, bacon, cheese, burger bun'
print("\nUpdated recipe of the 3rd food (Burger):", food_recipes_dict['Burger'])

# Delete the 7th food (Fried Rice) from the dictionary
del food_recipes_dict['Fried Rice']
print("\nDictionary after deleting the 7th food (Fried Rice):")
print(food_recipes_dict)

# Print the last key-value pair in the dictionary
last_key = list(food_recipes_dict.keys())[-1]
last_value = food_recipes_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

47. festival_locations_dict.py

  1. Create a dictionary of 8 festivals and their locations.

  2. Print the entire dictionary.

  3. Access and print the location of the 4th festival.

  4. Update the location of the 6th festival.

  5. Delete the 2nd festival from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Create a dictionary of 8 festivals and their locations
festival_locations_dict = {
    'Diwali': 'India',
    'Carnival': 'Brazil',
    'Oktoberfest': 'Germany',
    'Mardi Gras': 'USA',
    'Songkran': 'Thailand',
    'La Tomatina': 'Spain',
    'Holi': 'India',
    'Glastonbury': 'UK'
}

# Print the entire dictionary
print("The entire dictionary:")
print(festival_locations_dict)

# Access and print the location of the 4th festival (Mardi Gras)
fourth_festival_location = list(festival_locations_dict.values())[3]  # Index 3 for the 4th festival
print("\nLocation of the 4th festival (Mardi Gras):", fourth_festival_location)

# Update the location of the 6th festival (La Tomatina)
festival_locations_dict['La Tomatina'] = 'Spain (updated)'
print("\nUpdated location of the 6th festival (La Tomatina):", festival_locations_dict['La Tomatina'])

# Delete the 2nd festival (Carnival) from the dictionary
del festival_locations_dict['Carnival']
print("\nDictionary after deleting the 2nd festival (Carnival):")
print(festival_locations_dict)

# Print the last key-value pair in the dictionary
last_key = list(festival_locations_dict.keys())[-1]
last_value = festival_locations_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

48. beaches_countries_dict.py

  1. Create a dictionary of 8 beaches and the countries they are located in.

  2. Print the entire dictionary.

  3. Access and print the country of the 3rd beach.

  4. Update the country of the 6th beach.

  5. Delete the 5th beach from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Create a dictionary of 8 beaches and the countries they are located in
beaches_countries_dict = {
    'Bondi Beach': 'Australia',
    'Waikiki Beach': 'USA',
    'Copacabana Beach': 'Brazil',
    'Maya Bay': 'Thailand',
    'Santorini Beach': 'Greece',
    'Maldives Beach': 'Maldives',
    'Navagio Beach': 'Greece',
    'Zlatni Rat': 'Croatia'
}

# Print the entire dictionary
print("The entire dictionary:", beaches_countries_dict)

# Access and print the country of the 3rd beach (Copacabana Beach)
third_beach_country = list(beaches_countries_dict.values())[2]  # Index 2 for the 3rd beach
print("\nCountry of the 3rd beach (Copacabana Beach):", third_beach_country)

# Update the country of the 6th beach (Maldives Beach)
beaches_countries_dict['Maldives Beach'] = 'Sri Lanka'
print("\nUpdated country of the 6th beach (Maldives Beach):", beaches_countries_dict['Maldives Beach'])

# Delete the 5th beach (Santorini Beach) from the dictionary
del beaches_countries_dict['Santorini Beach']
print("\nDictionary after deleting the 5th beach (Santorini Beach):", beaches_countries_dict)

# Print the last key-value pair in the dictionary
last_key = list(beaches_countries_dict.keys())[-1]
last_value = beaches_countries_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

49. sports_events_dict.py

  1. Create a dictionary of 7 sports events and their corresponding years.

  2. Print the entire dictionary.

  3. Access and print the year of the 3rd sports event.

  4. Update the year of the 6th sports event.

  5. Delete the 5th sports event from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Create a dictionary of 7 sports events and their corresponding years
sports_events_dict = {
    'Olympic Games': 2020,
    'FIFA World Cup': 2022,
    'Super Bowl': 2021,
    'Tour de France': 2020,
    'Wimbledon': 2021,
    'NBA Finals': 2022,
    'UEFA Champions League Final': 2021
}

# Print the entire dictionary
print("The entire dictionary:", sports_events_dict)

# Access and print the year of the 3rd sports event (Super Bowl)
third_event_year = list(sports_events_dict.values())[2]  # Index 2 for the 3rd event
print("\nYear of the 3rd sports event (Super Bowl):", third_event_year)

# Update the year of the 6th sports event (NBA Finals)
sports_events_dict['NBA Finals'] = 2023
print("\nUpdated year of the 6th sports event (NBA Finals):", sports_events_dict['NBA Finals'])

# Delete the 5th sports event (Wimbledon) from the dictionary
del sports_events_dict['Wimbledon']
print("\nDictionary after deleting the 5th sports event (Wimbledon):", sports_events_dict)

# Print the last key-value pair in the dictionary
last_key = list(sports_events_dict.keys())[-1]
last_value = sports_events_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

50. technology_innovators_dict.py

  1. Create a dictionary of 8 technologies and their innovators.

  2. Print the entire dictionary.

  3. Access and print the innovator of the 4th technology.

  4. Update the innovator of the 2nd technology.

  5. Delete the 6th technology from the dictionary.

  6. Print the last key-value pair in the dictionary.

# Create a dictionary of 8 technologies and their innovators
technology_innovators_dict = {
    'Telephone': 'Alexander Graham Bell',
    'Light Bulb': 'Thomas Edison',
    'Airplane': 'Wright Brothers',
    'Computer': 'Charles Babbage',
    'Internet': 'Tim Berners-Lee',
    'Electric Motor': 'Nikola Tesla',
    'Laser': 'Theodore Maiman',
    'Smartphone': 'Steve Jobs'
}

# Print the entire dictionary
print("The entire dictionary:")
print(technology_innovators_dict)

# Access and print the innovator of the 4th technology (Computer)
fourth_technology_innovator = list(technology_innovators_dict.values())[3]  # Index 3 for the 4th technology
print("\nInnovator of the 4th technology (Computer):", fourth_technology_innovator)

# Update the innovator of the 2nd technology (Light Bulb)
technology_innovators_dict['Light Bulb'] = 'Joseph Swan'
print("\nUpdated innovator of the 2nd technology (Light Bulb):", technology_innovators_dict['Light Bulb'])

# Delete the 6th technology (Electric Motor) from the dictionary
del technology_innovators_dict['Electric Motor']
print("\nDictionary after deleting the 6th technology (Electric Motor):")
print(technology_innovators_dict)

# Print the last key-value pair in the dictionary
last_key = list(technology_innovators_dict.keys())[-1]
last_value = technology_innovators_dict[last_key]
print("\nThe last key-value pair in the dictionary:", (last_key, last_value))

https://github.com/JovRoncal/ACTIVITY-27-Master-the-Python-Dictionaries-Data-Structures