Master the Python Dictionaries Data Structures

This activity shows the different situations about dictionary data structures and how can we manipulate each python dictionaries, add, and commit files to the Github repository.
First, creating and setting up the Github repository named “Python Data Dictionary Data“
After this we can now set up the branch and continue doing the following
1. Add a student grade python dictionary and modify it
Code snippets:
studentsGrades = {
"Alice": 'A',
"Bob": 'B',
"Charlie": 'B+',
"David": 'A-',
"Eve": 'D'
}
print()
print(studentsGrades["Alice"])
print()
studentsGrades["Bob"] = "A"
print(studentsGrades["Bob"])
print()
del studentsGrades["Eve"]
last_key = list(studentsGrades.keys())[-1]
print(last_key, studentsGrades[last_key])
print()
2. Add a dictionaries of animal sounds
Code snippets:
animal_sounds = {
'Cat': 'Meow',
'Dog': 'Bark',
'Cow': 'Moo',
'Sheep': 'Baa',
'Lion': 'Roar',
'Elephant': 'Trumpet',
'Snake': 'Hiss',
'Duck': 'Quack'
}
print()
print(animal_sounds)
print()
print("Sound of fourth animal:", list(animal_sounds.values())[3])
print()
animal_sounds['Snake'] = 'Sssss'
print()
del animal_sounds['Lion']
print()
print("Last key-value pair:", list(animal_sounds.items())[-1])
print()
3. Add a dictionaries of city population
Code snippets:
city_population = {
'New York': 8419600,
'Los Angeles': 3980400,
'Chicago': 2716000,
'Houston': 2328000,
'Phoenix': 1690000,
'Philadelphia': 1584200,
'San Antonio': 1547200,
'San Diego': 1423851,
'Dallas': 1356000,
'San Jose': 1035200
}
print()
print(city_population)
print()
print("Population of sixth city:", list(city_population.values())[5])
print()
city_population['Chicago'] = 2800000
print()
del city_population['Dallas']
print()
print("Last key-value pair:", list(city_population.items())[-1])
print()
4. Add a dictionary of each countries capital
Code snippets:
countryCapitals = {
'USA': 'Washington, D.C.',
'Canada': 'Ottawa',
'UK': 'London',
'France': 'Paris',
'Germany': 'Berlin',
'Italy': 'Rome',
'Japan': 'Tokyo',
'China': 'Beijing',
'India': 'New Delhi',
'Russia': 'Moscow',
'Brazil': 'Brasilia',
'Australia': 'Canberra'
}
print()
print(countryCapitals)
print()
print("Capital of fifth country:", list(countryCapitals.values())[4])
print()
countryCapitals['China'] = 'Shanghai'
print()
del countryCapitals['Brazil']
print()
print("Last key-value pair:", list(countryCapitals.items())[-1])
print()
5. Added a dictionary of programming language
Code snippets:
programmingLanguages = {
'Python': 'Guido van Rossum',
'Java': 'James Gosling',
'C': 'Dennis Ritchie',
'JavaScript': 'Brendan Eich',
'C++': 'Bjarne Stroustrup',
'Ruby': 'Yukihiro Matsumoto',
'PHP': 'Rasmus Lerdorf'
}
print()
print(programmingLanguages)
print()
print("Developer of fourth language:", programmingLanguages['JavaScript'])
print()
programmingLanguages['Ruby'] = 'Matz'
print()
del programmingLanguages['Java']
print()
print("Last key-value pair:", list(programmingLanguages.items())[-1])
print()
6. Added a dictionary of car brands
Code snippets:
car_brands = {
'Toyota': 'Japan',
'Ford': 'USA',
'BMW': 'Germany',
'Mercedes': 'Germany',
'Honda': 'Japan',
'Chevrolet': 'USA',
'Hyundai': 'South Korea',
'Tesla': 'USA',
'Volkswagen': 'Germany',
'Ferrari': 'Italy'
}
print()
print(car_brands)
print()
print("Country of origin of third brand:", list(car_brands.values())[2])
print()
car_brands['Hyundai'] = 'South Korea'
print()
del car_brands['Tesla']
print()
print("Last key-value pair:", list(car_brands.items())[-1])
print()
7. Added a dictionary of book authors
Code snippets:
booksAuthors = {
'1984': 'George Orwell',
'To Kill a Mockingbird': 'Harper Lee',
'Pride and Prejudice': 'Jane Austen',
'The Great Gatsby': 'F. Scott Fitzgerald',
'Moby Dick': 'Herman Melville',
'War and Peace': 'Leo Tolstoy',
'The Catcher in the Rye': 'J.D. Salinger',
'Crime and Punishment': 'Fyodor Dostoevsky',
'The Lord of the Rings': 'J.R.R. Tolkien',
'The Hobbit': 'J.R.R. Tolkien',
'Ulysses': 'James Joyce',
'Brave New World': 'Aldous Huxley'
}
print()
print(booksAuthors)
print()
print("Author of ninth book:", list(booksAuthors.values())[8])
print()
booksAuthors['Moby Dick'] = 'Mark Twain'
print()
del booksAuthors['Pride and Prejudice']
print()
print("Last key-value pair:", list(booksAuthors.items())[-1])
print()
8. Adds the dictionary about colors of fruits
Code snippets:
fruitColors = {
'Apple': 'Red',
'Banana': 'Yellow',
'Grapes': 'Purple',
'Orange': 'Orange',
'Blueberry': 'Blue',
'Watermelon': 'Green',
'Strawberry': 'Red',
'Lemon': 'Yellow'
}
print()
print(fruitColors)
print()
print("Color of sixth fruit:", list(fruitColors.values())[5])
print()
fruitColors['Orange'] = 'Yellow-Orange'
print()
del fruitColors['Strawberry']
print()
print("Last key-value pair:", list(fruitColors.items())[-1])
print()
9. Add a dictionary of directors in movies
Code snippets:
movieDirectors = {
'Inception': 'Christopher Nolan',
'Titanic': 'James Cameron',
'Pulp Fiction': 'Quentin Tarantino',
'The Godfather': 'Francis Ford Coppola',
'The Dark Knight': 'Christopher Nolan',
'Avatar': 'James Cameron',
'Interstellar': 'Christopher Nolan',
'Fight Club': 'David Fincher',
'The Matrix': 'Lana Wachowski, Lilly Wachowski',
'The Shawshank Redemption': 'Frank Darabont'
}
print()
print(movieDirectors)
print()
print("Director of fifth movie:", list(movieDirectors.values())[4])
print()
movieDirectors['The Matrix'] = 'Wachowski Sisters'
print()
del movieDirectors['Interstellar']
print()
print("Last key-value pair:", list(movieDirectors.items())[-1])
print()
10. Add a dictionary about software companies
Code snippets:
softwareCompanies = {
'Microsoft': 'Redmond, WA',
'Google': 'Mountain View, CA',
'Apple': 'Cupertino, CA',
'Amazon': 'Seattle, WA',
'Facebook': 'Menlo Park, CA',
'IBM': 'Armonk, NY',
'Oracle': 'Austin, TX',
'Salesforce': 'San Francisco, CA',
'Adobe': 'San Jose, CA',
'Intel': 'Santa Clara, CA'
}
print()
print(softwareCompanies)
print()
print("Headquarters of third company:", list(softwareCompanies.values())[2])
print()
softwareCompanies['Salesforce'] = 'Los Angeles, CA'
print()
del softwareCompanies['Adobe']
print()
print("Last key-value pair:", list(softwareCompanies.items())[-1])
print()
11. Adding a dictionary about sport players
Code snippets:
sportsPlayers = {
'Soccer': 'Lionel Messi',
'Basketball': 'Michael Jordan',
'Tennis': 'Roger Federer',
'Cricket': 'Sachin Tendulkar',
'Football': 'Tom Brady',
'Golf': 'Tiger Woods',
'Baseball': 'Babe Ruth',
'Swimming': 'Michael Phelps',
'Boxing': 'Muhammad Ali',
'Track': 'Usain Bolt'
}
print()
print(sportsPlayers)
print()
print("Player of fourth sport:", sportsPlayers['Cricket'])
print()
sportsPlayers['Golf'] = 'Jack Nicklaus'
print()
del sportsPlayers['Track']
print()
print("Last key-value pair:", list(sportsPlayers.items())[-1])
print()
12. Adding a dictionaries about courses in university
Code snippets:
universityCourses = {
'Harvard': 'Law',
'MIT': 'Computer Science',
'Stanford': 'Business',
'Oxford': 'Philosophy',
'Cambridge': 'Engineering',
'Caltech': 'Physics',
'Yale': 'Political Science',
'Princeton': 'Mathematics'
}
print()
print(universityCourses)
print()
print("Course of third university:", universityCourses['Stanford'])
print()
universityCourses['Cambridge'] = 'Artificial Intelligence'
print()
del universityCourses['Yale']
print()
print("Last key-value pair:", list(universityCourses.items())[-1])
print()
13. Adds a dictionary of element symbols
Code snippets:
elementSymbols = {
'Hydrogen': 'H',
'Helium': 'He',
'Lithium': 'Li',
'Beryllium': 'Be',
'Boron': 'B',
'Carbon': 'C',
'Nitrogen': 'N',
'Oxygen': 'O',
'Fluorine': 'F',
'Neon': 'Ne'
}
print()
print(elementSymbols)
print()
print("Symbol of sixth element:", list(elementSymbols.values())[5])
print()
elementSymbols['Oxygen'] = 'O2'
print()
del elementSymbols['Fluorine']
print()
print("Last key-value pair:", list(elementSymbols.items())[-1])
print()
14. Added a dictionary about countries in every continent
Code snippets:
continentCountries = {
'Africa': ['Nigeria', 'Kenya', 'South Africa'],
'Asia': ['China', 'India', 'Japan'],
'Europe': ['France', 'Germany', 'Italy'],
'North America': ['USA', 'Canada', 'Mexico'],
'South America': ['Brazil', 'Argentina', 'Chile'],
'Australia': ['Australia', 'New Zealand', 'Fiji']
}
print()
print(continentCountries)
print()
print("Countries of fourth continent:", continentCountries['North America'])
print()
continentCountries['South America'] = ['Colombia', 'Peru', 'Venezuela']
print()
del continentCountries['Australia']
print()
print("Last key-value pair:", list(continentCountries.items())[-1])
print()
15. Added a dictionaty about animal habitats
Code snippets:
animalHabitats = {
'Lion': 'Savannah',
'Polar Bear': 'Arctic',
'Kangaroo': 'Grasslands',
'Elephant': 'Forests',
'Penguin': 'Antarctica',
'Wolf': 'Tundra',
'Shark': 'Ocean',
'Gorilla': 'Rainforest'
}
print()
print(animalHabitats)
print()
print("Habitat of third animal:", animalHabitats['Kangaroo'])
print()
animalHabitats['Penguin'] = 'Cold Coastal Regions'
print()
del animalHabitats['Shark']
print()
print("Last key-value pair:", list(animalHabitats.items())[-1])
print()
16. Add a dictionary about CEO's
Code snippets:
companyCeos = {
'Apple': 'Tim Cook',
'Google': 'Sundar Pichai',
'Microsoft': 'Satya Nadella',
'Amazon': 'Andy Jassy',
'Tesla': 'Elon Musk',
'Facebook': 'Mark Zuckerberg',
'IBM': 'Arvind Krishna',
'Oracle': 'Safra Catz',
'Salesforce': 'Marc Benioff',
'Netflix': 'Ted Sarandos'
}
print()
print(companyCeos)
print()
print("CEO of sixth company:", companyCeos['Facebook'])
print()
companyCeos['Microsoft'] = 'Bill Gates'
print()
del companyCeos['Salesforce']
print()
print("Last key-value pair:", list(companyCeos.items())[-1])
print()
17. Adds a dictionary about space missions
Code snippets:
spaceMissions = {
'Apollo 11': 1969,
'Voyager 1': 1977,
'Mars Rover': 2004,
'Hubble Telescope': 1990,
'Cassini': 1997
}
print()
print(spaceMissions)
print()
print("Year of third mission:", spaceMissions['Mars Rover'])
print()
spaceMissions['Voyager 1'] = 1978
print()
del spaceMissions['Hubble Telescope']
print()
print("Last key-value pair:", list(spaceMissions.items())[-1])
print()
18. Adds a dictionary about flower meanings
Code snippets:
flowerMeanings = {
'Rose': 'Love',
'Lily': 'Purity',
'Tulip': 'Perfect Love',
'Daisy': 'Innocence',
'Sunflower': 'Adoration',
'Orchid': 'Strength',
'Lavender': 'Serenity',
'Carnation': 'Admiration'
}
print()
print(flowerMeanings)
print()
print("Meaning of fifth flower:", flowerMeanings['Sunflower'])
print()
flowerMeanings['Lavender'] = 'Calmness'
print()
del flowerMeanings['Orchid']
print()
print("Last key-value pair:", list(flowerMeanings.items())[-1])
print()
19. Adds a dictionary about dates of holidays
Code snippets:
holidayDates = {
'New Year': 'January 1',
'Independence Day': 'July 4',
'Christmas': 'December 25',
'Thanksgiving': 'November 23',
'Labor Day': 'September 5',
'Halloween': 'October 31',
'Valentine\'s Day': 'February 14',
'Easter': 'April 17',
'Memorial Day': 'May 30',
'Veterans Day': 'November 11'
}
print()
print(holidayDates)
print()
print("Date of fourth holiday:", holidayDates['Thanksgiving'])
print()
holidayDates['Memorial Day'] = 'May 31'
print()
del holidayDates['Independence Day']
print()
print("Last key-value pair:", list(holidayDates.items())[-1])
print()
20. Adds a dictionary about river lengths
Code snippets:
riverLengths = {
'Nile': 6650,
'Amazon': 6400,
'Yangtze': 6300,
'Mississippi': 3730,
'Yenisei': 5539,
'Yellow River': 5464
}
print()
print(riverLengths)
print()
print("Length of second river:", riverLengths['Amazon'])
print()
riverLengths['Yenisei'] = 5540
print()
del riverLengths['Mississippi']
print()
print("Last key-value pair:", list(riverLengths.items())[-1])
print()
21. Adds a dictionary about ratings on app store
Code snippets:
appStoreRatings = {
'Instagram': 4.5,
'Facebook': 3.8,
'WhatsApp': 4.7,
'TikTok': 4.2,
'Snapchat': 3.9,
'Spotify': 4.8,
'YouTube': 4.6,
'Netflix': 4.4,
'Zoom': 4.3,
'Discord': 4.6
}
print()
print(appStoreRatings)
print()
print("Rating of sixth app:", appStoreRatings['Spotify'])
print()
appStoreRatings['Netflix'] = 4.5
print()
del appStoreRatings['Zoom']
print()
print("Last key-value pair:", list(appStoreRatings.items())[-1])
print()
22. Adds a dictionary about movie genres
Code snippets:
movieGenres = {
'Action': 'Mad Max: Fury Road',
'Drama': 'The Godfather',
'Comedy': 'Superbad',
'Horror': 'The Exorcist',
'Science Fiction': 'Blade Runner',
'Fantasy': 'The Lord of the Rings',
'Romance': 'The Notebook',
'Thriller': 'Inception'
}
print()
print(movieGenres)
print()
print("Example movie of third genre:", movieGenres['Comedy'])
print()
movieGenres['Science Fiction'] = 'Interstellar'
print()
del movieGenres['Romance']
print()
print("Last key-value pair:", list(movieGenres.items())[-1])
print()
23. Add a dictionary about technology inventions
Code snippets:
technologyInventors = {
'Telephone': 'Alexander Graham Bell',
'Light Bulb': 'Thomas Edison',
'Airplane': 'Wright Brothers',
'Computer': 'Charles Babbage',
'Internet': 'Vint Cerf',
'Radio': 'Guglielmo Marconi'
}
print()
print(technologyInventors)
print()
print("Inventor of fourth technology:", technologyInventors['Computer'])
print()
technologyInventors['Light Bulb'] = 'Nikola Tesla'
print()
del technologyInventors['Radio']
print()
print("Last key-value pair:", list(technologyInventors.items())[-1])
print()
24. Adds a dictionary about currency symbols
Code snippets:
currencySymbols = {
'US Dollar': '$',
'Euro': '€',
'British Pound': '£',
'Japanese Yen': '¥',
'Indian Rupee': '₹',
'Australian Dollar': 'A$',
'Canadian Dollar': 'C$',
'Swiss Franc': 'CHF',
'Chinese Yuan': '¥',
'Russian Ruble': '₽'
}
print()
print(currencySymbols)
print()
print("Symbol of fifth currency:", currencySymbols['Indian Rupee'])
print()
currencySymbols['Chinese Yuan'] = 'C¥'
print()
del currencySymbols['British Pound']
print()
print("Last key-value pair:", list(currencySymbols.items())[-1])
print()
print()
25. Adds a dictionary about video games
Code snippets:
videoGamePlatforms = {
'The Legend of Zelda': 'Nintendo Switch',
'Fortnite': 'PlayStation 4',
'Minecraft': 'PC',
'Call of Duty': 'Xbox One',
'GTA V': 'PC',
'Among Us': 'Mobile',
'League of Legends': 'PC',
'FIFA 21': 'PlayStation 4'
}
print()
print(videoGamePlatforms)
print()
print("Platform of second video game:", videoGamePlatforms['Fortnite'])
print()
videoGamePlatforms['Among Us'] = 'PC'
print()
del videoGamePlatforms['Call of Duty']
print()
print("Last key-value pair:", list(videoGamePlatforms.items())[-1])
print()
26. Add a dictionary about planet distances
Code snippets:
planetDistances = {
'Mercury': 57.9,
'Venus': 108.2,
'Earth': 149.6,
'Mars': 227.9,
'Jupiter': 778.5,
'Saturn': 1433.5,
'Uranus': 2871.0,
'Neptune': 4497.1
}
print()
print(planetDistances)
print()
print("Distance of third planet:", planetDistances['Earth'])
print()
planetDistances['Jupiter'] = 780.0
print()
del planetDistances['Uranus']
print()
print("Last key-value pair:", list(planetDistances.items())[-1])
print()
27. Adds a dictionary about product price
Code snippets:
productPrices = {
'Laptop': 999.99,
'Smartphone': 699.99,
'Tablet': 299.99,
'Headphones': 149.99,
'Smartwatch': 199.99,
'Camera': 499.99,
'TV': 799.99,
'Refrigerator': 1200.00,
'Microwave': 100.00,
'Washing Machine': 700.00
}
print()
print(productPrices)
print()
print("Price of fourth product:", productPrices['Headphones'])
print()
productPrices['Microwave'] = 120.00
print()
del productPrices['Camera']
print()
print("Last key-value pair:", list(productPrices.items())[-1])
print()
print()
28. Adds a dictionary about athlete achievements
Code snippets:
athleteAchievements = {
'Michael Jordan': '6 NBA Championships',
'Usain Bolt': '8 Olympic Gold Medals',
'Serena Williams': '23 Grand Slam Titles',
'Tom Brady': '7 Super Bowl Wins',
'Lionel Messi': '7 Ballon d\'Or Awards',
'Cristiano Ronaldo': '5 Ballon d\'Or Awards',
'Tiger Woods': '15 Major Golf Championships',
'Roger Federer': '20 Grand Slam Titles'
}
print()
print(athleteAchievements)
print()
print("Achievement of fifth athlete:", athleteAchievements['Lionel Messi'])
print()
athleteAchievements['Serena Williams'] = '24 Grand Slam Titles'
print()
del athleteAchievements['Tiger Woods']
print()
print("Last key-value pair:", list(athleteAchievements.items())[-1])
print()
print()
29. Adds a dictionary about phone models
Code snippets:
phoneModels = {
'iPhone 13': 'Apple',
'Galaxy S21': 'Samsung',
'Pixel 6': 'Google',
'OnePlus 9': 'OnePlus',
'Xperia 5': 'Sony',
'Mi 11': 'Xiaomi',
'P40': 'Huawei',
'Moto G Power': 'Motorola',
'Redmi Note 10': 'Xiaomi',
'Oppo Reno 6': 'Oppo'
}
print()
print(phoneModels)
print()
print("Manufacturer of second phone model:", phoneModels['Galaxy S21'])
print()
phoneModels['Moto G Power'] = 'Lenovo'
print()
del phoneModels['Mi 11']
print()
print("Last key-value pair:", list(phoneModels.items())[-1])
print()
print()
30. Adds a dictionary about software versions
Code snippets:
softwareVersions = {
'Windows': '11.0',
'macOS': '12.3',
'Ubuntu': '22.04',
'Photoshop': '23.1',
'Chrome': '104.0',
'Firefox': '100.0'
}
print()
print(softwareVersions)
print()
print("Version of fourth software:", softwareVersions['Photoshop'])
print()
softwareVersions['macOS'] = '12.4'
print()
del softwareVersions['Chrome']
print()
print("Last key-value pair:", list(softwareVersions.items())[-1])
print()
31. Adds a dictionary about festival dates
Code snippets:
festivalDates = {
'Christmas': '25th December',
'Diwali': '4th November',
'Eid al-Fitr': '13th May',
'Hanukkah': '28th November',
'Thanksgiving': '25th November',
'New Year\'s Eve': '31st December',
'Holi': '29th March',
'Easter': '4th April',
'Ramadan': '12th April',
'Halloween': '31st October'
}
print()
print(festivalDates)
print()
print("Date of third festival:", festivalDates['Eid al-Fitr'])
print()
festivalDates['Holi'] = '18th March'
print()
del festivalDates['Thanksgiving']
print()
print("Last key-value pair:", list(festivalDates.items())[-1])
print()
32. Adds a dictionary about company founders
Code snippets:
companyFounders = {
'Apple': 'Steve Jobs',
'Microsoft': 'Bill Gates',
'Google': 'Larry Page',
'Amazon': 'Jeff Bezos',
'Facebook': 'Mark Zuckerberg',
'Tesla': 'Elon Musk',
'SpaceX': 'Elon Musk',
'Netflix': 'Reed Hastings'
}
print()
print(companyFounders)
print()
print("Founder of sixth company:", companyFounders['Tesla'])
print()
companyFounders['Microsoft'] = 'Paul Allen'
print()
del companyFounders['Netflix']
print()
print("Last key-value pair:", list(companyFounders.items())[-1])
print()
print()
33. Adds a dictionary about cars specs
Code snippets:
carSpecs = {
'Toyota Camry': '2.5L 4-cylinder',
'Ford Mustang': '5.0L V8',
'Honda Accord': '1.5L turbo',
'Chevrolet Camaro': '6.2L V8',
'Tesla Model S': 'Electric',
'BMW 3 Series': '2.0L 4-cylinder',
'Audi A4': '2.0L 4-cylinder',
'Mercedes C-Class': '2.0L 4-cylinder',
'Porsche 911': '3.0L turbocharged flat-6',
'Lexus RX': '3.5L V6'
}
print()
print(carSpecs)
print()
print("Specifications of fourth car model:", carSpecs['Chevrolet Camaro'])
print()
carSpecs['Porsche 911'] = '4.0L flat-6'
print()
del carSpecs['Tesla Model S']
print()
print("Last key-value pair:", list(carSpecs.items())[-1])
print()
print()
34. Adds a dictionary about artist songs
Code snippets:
artistSongs = {
'Taylor Swift': 'Love Story',
'Ed Sheeran': 'Shape of You',
'Adele': 'Hello',
'Drake': 'God’s Plan',
'Beyoncé': 'Halo',
'Bruno Mars': 'Uptown Funk',
'Billie Eilish': 'Bad Guy',
'The Weeknd': 'Blinding Lights'
}
print()
print(artistSongs)
print()
print("Top song of third artist:", artistSongs['Adele'])
print()
artistSongs['Bruno Mars'] = 'Just the Way You Are'
print()
del artistSongs['Billie Eilish']
print()
print("Last key-value pair:", list(artistSongs.items())[-1])
print()
print()
35. Adds a dictionary about dog breeds
Code snippets:
dogBreeds = {
'Labrador Retriever': 'Large',
'Beagle': 'Medium',
'Bulldog': 'Medium',
'Poodle': 'Small',
'German Shepherd': 'Large',
'Dachshund': 'Small',
'Golden Retriever': 'Large',
'Shih Tzu': 'Small',
'Chihuahua': 'Small',
'Great Dane': 'Large'
}
print()
print(dogBreeds)
print()
print("Size of fifth breed:", dogBreeds['German Shepherd'])
print()
dogBreeds['Shih Tzu'] = 'Medium'
print()
del dogBreeds['Dachshund']
print()
print("Last key-value pair:", list(dogBreeds.items())[-1])
print()
print()
36. Adds a dictionary about historical events
Code snippets:
historicalEvents = {
'Fall of the Berlin Wall': 1989,
'Moon Landing': 1969,
'Declaration of Independence': 1776,
'World War II End': 1945,
'French Revolution': 1789,
'Renaissance Period': 1400,
'9/11 Attacks': 2001,
'COVID-19 Pandemic': 2020
}
print()
print(historicalEvents)
print()
print("Year of second event:", historicalEvents['Moon Landing'])
print()
historicalEvents['9/11 Attacks'] = 2000
print()
del historicalEvents['French Revolution']
print()
print("Last key-value pair:", list(historicalEvents.items())[-1])
print()
37. Adds a dictionary about capitals in states in america
Code snippets:
stateCapitals = {
'California': 'Sacramento',
'Texas': 'Austin',
'New York': 'Albany',
'Florida': 'Tallahassee',
'Illinois': 'Springfield',
'Ohio': 'Columbus',
'Georgia': 'Atlanta',
'Michigan': 'Lansing',
'Pennsylvania': 'Harrisburg',
'Washington': 'Olympia'
}
print()
print(stateCapitals)
print()
print("Capital of fourth state:", stateCapitals['Florida'])
print()
stateCapitals['Pennsylvania'] = 'Philadelphia'
print()
del stateCapitals['Georgia']
print()
print("Last key-value pair:", list(stateCapitals.items())[-1])
print()
print()
38. Adds a dictionary about plant types
Code snippets:
plantTypes = {
'Rose': 'Shrub',
'Oak': 'Tree',
'Basil': 'Herb',
'Sunflower': 'Flower',
'Pine': 'Tree',
'Cactus': 'Succulent',
'Tulip': 'Flower',
'Mint': 'Herb'
}
print()
print(plantTypes)
print()
print("Type of fifth plant:", plantTypes['Pine'])
print()
plantTypes['Oak'] = 'Shrub'
print()
del plantTypes['Cactus']
print()
print("Last key-value pair:", list(plantTypes.items())[-1])
print()
print()
39. Adds a dictionary about space telescope
Code snippets:
spaceTelescopes = {
'Hubble': 'Study distant galaxies',
'James Webb': 'Observe infrared light from the early universe',
'Chandra': 'X-ray observations of black holes',
'Kepler': 'Search for exoplanets',
'Spitzer': 'Infrared study of space objects'
}
print()
print(spaceTelescopes)
print()
print("Mission of third telescope:", spaceTelescopes['Chandra'])
print()
spaceTelescopes['Hubble'] = 'Explore deep space and star formation'
print()
del spaceTelescopes['Kepler']
print()
print("Last key-value pair:", list(spaceTelescopes.items())[-1])
print()
print()
40. Adds a dicionary about dinosaur fossils
Code snippets:
dinosaurFossils = {
'Tyrannosaurus Rex': 'North America',
'Stegosaurus': 'Western United States',
'Triceratops': 'Montana, USA',
'Velociraptor': 'Mongolia',
'Brachiosaurus': 'Tanzania',
'Spinosaurus': 'North Africa',
'Diplodocus': 'Colorado, USA'
}
print()
print(dinosaurFossils)
print()
print("Fossil location of fourth dinosaur:", dinosaurFossils['Velociraptor'])
print()
dinosaurFossils['Stegosaurus'] = 'Utah, USA'
print()
del dinosaurFossils['Spinosaurus']
print()
print("Last key-value pair:", list(dinosaurFossils.items())[-1])
print()
print()
41. Adds a dictionary about author book
Code snippets:
authorBooks = {
'J.K. Rowling': 'Harry Potter',
'George Orwell': '1984',
'J.R.R. Tolkien': 'The Lord of the Rings',
'Agatha Christie': 'Murder on the Orient Express',
'Mark Twain': 'The Adventures of Tom Sawyer',
'F. Scott Fitzgerald': 'The Great Gatsby',
'Ernest Hemingway': 'The Old Man and the Sea',
'Leo Tolstoy': 'War and Peace'
}
print()
print(authorBooks)
print()
print("Book of fifth author:", authorBooks['Mark Twain'])
print()
authorBooks['Ernest Hemingway'] = 'A Farewell to Arms'
print()
del authorBooks['F. Scott Fitzgerald']
print()
print("Last key-value pair:", list(authorBooks.items())[-1])
print()
print()
42. Adds a dictionary about coffee types
Code snippets:
coffeeTypes = {
'Espresso': 'Strong coffee brewed by forcing steam through ground coffee beans',
'Latte': 'Espresso with steamed milk and a small layer of foam',
'Cappuccino': 'Equal parts espresso, steamed milk, and foam',
'Americano': 'Espresso with added hot water',
'Macchiato': 'Espresso with a small amount of milk or foam',
'Mocha': 'Espresso mixed with chocolate syrup and steamed milk',
'Flat White': 'Espresso with steamed milk and no foam',
'Affogato': 'Espresso poured over a scoop of ice cream',
'Cortado': 'Equal parts espresso and steamed milk',
'Irish Coffee': 'Coffee with whiskey and sugar, topped with cream'
}
print()
print(coffeeTypes)
print()
print("Description of fourth coffee:", coffeeTypes['Americano'])
print()
coffeeTypes['Affogato'] = 'Espresso poured over vanilla ice cream'
print()
del coffeeTypes['Macchiato']
print()
print("Last key-value pair:", list(coffeeTypes.items())[-1])
print()
43. Adds a dictionary about job salaries
Code snippets:
jobSalaries = {
'Software Engineer': '$120,000',
'Data Scientist': '$130,000',
'Product Manager': '$110,000',
'Marketing Manager': '$90,000',
'Graphic Designer': '$65,000',
'Accountant': '$70,000',
'Doctor': '$200,000',
'Teacher': '$50,000',
'Lawyer': '$150,000',
'Nurse': '$80,000'
}
print()
print(jobSalaries)
print()
print("Salary of third job:", jobSalaries['Product Manager'])
print()
jobSalaries['Doctor'] = '$210,000'
print()
del jobSalaries['Lawyer']
print()
print("Last key-value pair:", list(jobSalaries.items())[-1])
print()
print()
44. Adds a dictionary about food recipes
Code snippets:
foodRecipesDict = {
"Spaghetti": "Boil water, cook pasta, add sauce",
"Tacos": "Prepare meat, add toppings, fill tortillas",
"Pizza": "Prepare dough, add sauce, toppings, and bake",
"Salad": "Chop vegetables, add dressing",
"Pancakes": "Mix batter, cook on griddle",
"Soup": "Boil broth, add vegetables and spices",
"Omelette": "Whisk eggs, cook in pan, add fillings",
"Brownies": "Mix ingredients, bake in oven"
}
print()
print(foodRecipesDict)
print()
print("Recipe of Pancakes:", foodRecipesDict["Pancakes"])
print()
foodRecipesDict["Pizza"] = "Prepare dough, add sauce, cheese, and bake"
print()
del foodRecipesDict["Omelette"]
print()
last_key = list(foodRecipesDict.keys())[-1]
print("Last key-value pair:", last_key, ":", foodRecipesDict[last_key])
print()
print()
45. Adds a dictionary about festival locations
Code snippets:
festivalLocationsDict = {
"Diwali": "India",
"Carnival": "Brazil",
"Oktoberfest": "Germany",
"Mardi Gras": "USA",
"Chinese New Year": "China",
"La Tomatina": "Spain",
"Holi": "India",
"St. Patrick's Day": "Ireland"
}
print()
print(festivalLocationsDict)
print()
print("Location of Mardi Gras:", festivalLocationsDict["Mardi Gras"])
print()
festivalLocationsDict["La Tomatina"] = "Valencia, Spain"
print()
del festivalLocationsDict["Carnival"]
print()
last_key = list(festivalLocationsDict.keys())[-1]
print("Last key-value pair:", last_key, ":", festivalLocationsDict[last_key])
print()
46. Adds a dictionary about beacches in every country
Code snippets:
beachesCountriesDict = {
"Bondi Beach": "Australia",
"Copacabana": "Brazil",
"Waikiki Beach": "USA",
"Whitehaven Beach": "Australia",
"Anse Source d'Argent": "Seychelles",
"Navagio Beach": "Greece",
"Tulum Beach": "Mexico",
"Bora Bora Beach": "French Polynesia"
}
print()
print(beachesCountriesDict)
print()
print("Country of Waikiki Beach:", beachesCountriesDict["Waikiki Beach"])
print()
beachesCountriesDict["Navagio Beach"] = "Zakynthos, Greece"
print()
del beachesCountriesDict["Anse Source d'Argent"]
print()
last_key = list(beachesCountriesDict.keys())[-1]
print("Last key-value pair:", last_key, ":", beachesCountriesDict[last_key])
print()
print()
47. Adds a dictionary about sports event in the world
Code snippets:
sportsEventsDict = {
"Olympics": 2021,
"FIFA World Cup": 2022,
"Super Bowl": 2023,
"Wimbledon": 2023,
"Tour de France": 2023,
"Cricket World Cup": 2023,
"Ryder Cup": 2023
}
print()
print(sportsEventsDict)
print()
print("Year of Super Bowl:", sportsEventsDict["Super Bowl"])
print()
sportsEventsDict["Cricket World Cup"] = 2024
print()
del sportsEventsDict["Tour de France"]
print()
last_key = list(sportsEventsDict.keys())[-1]
print("Last key-value pair:", last_key, ":", sportsEventsDict[last_key])
print()
48. Adds a dictionary about technology innovators
Code snippets:
technologyInnovators = {
"Internet": "Vint Cerf",
"Telephone": "Alexander Graham Bell",
"Electric Lightbulb": "Thomas Edison",
"Airplane": "Wright Brothers",
"Personal Computer": "Steve Jobs & Bill Gates",
"World Wide Web": "Tim Berners-Lee",
"Nuclear Reactor": "Enrico Fermi",
"Bluetooth": "Jaap Haartsen"
}
print()
print(technologyInnovators)
print()
print("Innovator of Airplane:", technologyInnovators["Airplane"])
print()
technologyInnovators["Telephone"] = "Elisha Gray"
print()
del technologyInnovators["World Wide Web"]
print()
last_key = list(technologyInnovators.keys())[-1]
print("Last key-value pair:", last_key, ":", technologyInnovators[last_key])
print()
print()
49. Adds a video game dictionary
Code snippets:
videoGamePlatforms = {
'The Legend of Zelda': 'Nintendo Switch',
'Fortnite': 'PlayStation 4',
'Minecraft': 'PC',
'Call of Duty': 'Xbox One',
'GTA V': 'PC',
'Among Us': 'Mobile',
'League of Legends': 'PC',
'FIFA 21': 'PlayStation 4'
}
print()
print(videoGamePlatforms)
print()
print("Platform of second video game:", videoGamePlatforms['Fortnite'])
print()
videoGamePlatforms['Among Us'] = 'PC'
print()
del videoGamePlatforms['Call of Duty']
print()
print("Last key-value pair:", list(videoGamePlatforms.items())[-1])
print()
50. Create a landmarks python file and created to complete the task
Code snippets:
cityLandmarks = {
"Paris": "Eiffel Tower",
"New York": "Statue of Liberty",
"Rome": "Colosseum",
"London": "Big Ben",
"Beijing": "Great Wall of China",
"Cairo": "Pyramids of Giza",
"Sydney": "Sydney Opera House",
"Rio de Janeiro": "Christ the Redeemer"
}
print()
print("City Landmarks Dictionary:", cityLandmarks)
print()
print("Landmark of Cairo:", cityLandmarks["Cairo"])
print()
cityLandmarks["New York"] = "Empire State Building"
print()
del cityLandmarks["Sydney"]
print()
last_key = list(cityLandmarks.keys())[-1]
print("Last key-value pair:", last_key, ":", cityLandmarks[last_key])
print()



