Learn the dictionary data structures in python
- From Byte of Python read the following chapters
- Data structures read dictionary section
- From Dive into Python3, read the following chapters
- Native data types - read dictionary section
After completing the exercises below, you should be comfortable with
- Using dictionaries
★☆☆ - Easy
★★☆ - Medium
★★★ - Challenging
★★★★ - Bonus
a -> 2,
c -> 5,
b -> 1,
d -> 3
what is the value for key 'a'?
what is the value for key 'x' ?
Add e -> 4 to the above map
key : 'a'
key : 'x'
For example the dict has following KV
a -> 2,
c -> 5,
b -> 1,
d -> 3
existing key : d['a'] --> 2
non existing key returns zero : d['x'] --> 0
- Create a list of 50 random numbers between 1 and 100 (including).
- print only unique numbers from the list, eliminating duplicates
For example if the list is
['a', 'b', 'a', 'c', 'b', 'a']
Expected output is :
'a' -> 3,
'b' -> 2,
'c' -> 1
For example, if the dictionary is
a -> 4
b -> 5
c -> 2
The expected output is :
c -> 2
a -> 4
b -> 5