Explore Dictionary Keys, Values, and Items
๐ Scenario: You work in a small bookstore. You have a dictionary that stores book titles as keys and their prices as values.You want to learn how to get just the book titles, just the prices, and both together in pairs.
๐ฏ Goal: Build a program that shows how to get the keys, values, and items from a dictionary.
๐ What You'll Learn
Create a dictionary called
books with exact entries: 'Python Basics': 29.99, 'Data Science': 39.95, 'Machine Learning': 49.50Create a variable called
book_titles that stores the keys of booksCreate a variable called
book_prices that stores the values of booksCreate a variable called
book_items that stores the items of booksPrint
book_titles, book_prices, and book_items in that order๐ก Why This Matters
๐ Real World
Dictionaries are used to store related data, like product names and prices, user information, or settings. Knowing how to get keys, values, and items helps you access and use this data easily.
๐ผ Career
Many programming jobs require working with dictionaries or similar data structures. Being comfortable with keys, values, and items is essential for data processing, web development, and automation tasks.
Progress0 / 4 steps