0% found this document useful (0 votes)
4 views1 page

Essential Dictionary Operations in Python

Uploaded by

gtecstudent795
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Essential Dictionary Operations in Python

Uploaded by

gtecstudent795
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Basic Level

1. Create a dictionary with 3 key-value pairs representing a person’s name, age, and
city.
2. Access a value from a dictionary by its key and print it.
3. Update the value of an existing key in the dictionary.
4. Add a new key-value pair to an existing dictionary.
5. Delete a key from the dictionary using del.
6. Check if a key exists in a dictionary using in.

Intermediate Level

7. Loop through a dictionary and print all keys and values.


8. Count the frequency of characters in a string and store them in a dictionary.
9. Merge two dictionaries into one.
10. Create a dictionary from two lists, one as keys and the other as values.
11. Sort a dictionary by values in ascending order.
12. Create a nested dictionary representing student data (name, subjects with marks).
13. Find the key with the maximum value in a dictionary.
14. Remove duplicates from a dictionary where values are duplicated.
15. Write a function that takes a dictionary and returns the average of all numerical
values.

You might also like