Dictionary
A dictionary is an unordered collection of key-value pairs. It is useful for storing and retrieving data using specific keys. A dictionary is like a book with definitions. It has words (keys) and their meanings (values). Each word has a unique meaning.
Example 1: If we have to save details of a person then we can use the dictionary.
Python
person = { "name" : "Bob" , "age" : 12 , "country" : "USA" } print (person) |
{'country': 'USA', 'age': 12, 'name': 'Bob'}
Let’s understand Dictionary in Python with one more example:
Example 2: Animals = {“lion”: “Lions are known as the kings of the jungle”, “elephant”: “Elephants have a great memory”}.
In this dictionary, you can look up an animal’s name and find its corresponding fun fact.
Python
Animals = { "lion" : "Lions are known as the kings of the jungle" , "elephant" : "Elephants have a great memory" } print (Animals) |
{'lion': 'Lions are known as the kings of the jungle', 'elephant': 'Elephants have a great memory'}
Play with Dictionary in Python:
- How to find the sum of all items in a dictionary
- How to find the size of a Dictionary
- Find Key with maximum unique values
- Replace words from Dictionary
- Remove Dictionary Key Words
- Counting the frequencies in a list using dictionary in Python
- Remove duplicate values across Dictionary Values
- Find Dictionary Values Mean
Python for Kids – Fun Tutorial to Learn Python Programming
Python for Kids – Python is an easy-to-understand and good-to-start programming language. In this Python tutorial for kids or beginners, you will learn Python and know why it is a perfect fit for kids to start. Whether the child is interested in building simple games, creating art, or solving puzzles, Python provides the foundation to the kids or any beginner for their coding journey.
Programming is an essential skill in today’s world because programming is used everywhere in our surroundings. And to learn programming, we have to learn a programming language and Python is the best to start with programming language. It has a simple syntax and readability is the best choice for kids to understand programming concepts. In this Python tutorial, you’ll learn all the basic concepts, installation processes, and fundamental programming concepts.
Contact Us