Name – Arik Surin
Roll no - 07
Class – 11
Section – ‘A’
Subject – Computer Science
Subject Teacher – Sachit Sir
CERTIFICATE
This is to certify that Uday Kishore Sharma of class
XI A of NML KERALA PUBLIC SCHOOL has
successfully completed his Computer Science Project
on “A menu driven program of dictionary to demonstrate
various functions of dictionary”. This candidate has taken
proper care and outmost sincerity in completion of his
project. All the work related to the project was done by
the candidate. The approach towards the subject has
been sincere.
I certify that this project is up to my expectations and as
per the guidelines issued by CBSE.
Signature of Internal Signature of External
Examiner : Examiner :
----------------------------
------------------------------
Signature of Principal
--------------------------
Acknowledgement
I would like to extend my sincere gratitude to all those
who contributed to the successful completion of this
project. First and foremost, I would like to thank our
principal, Mrs. Gurmeet Kaur for providing us with
the opportunity and resources to carry out this project.
Your unwavering support and encouragement have
been invaluable. I am deeply grateful to my teachers,
Sachit Sir for their guidance, insightful feedback, and
patience throughout the project. Your expertise and
dedication have been instrumental in shaping this
work. I would also like to express my appreciation to my
classmates and friends for their cooperation,
collaboration, and moral support. Your camaraderie
made this journey enjoyable and enriching.
Finally, I would like to acknowledge my family for their
constant support and understanding. Your
encouragement has been a source of motivation for
me. Thank you all for your contributions and support.
Introduction
This program is designed to allow users to interact with a dictionary
data structure through a menu-driven interface. Here’s a brief
overview:
1. Adding a Key-Value Pair: Users can add new key-value pairs to
the dictionary.
2. Updating a Key-Value Pair: If a key exists, users can update its
value.
3. Removing a Key-Value Pair: Users can remove a key-value pair if
the key exists.
4. Checking if a Key Exists: Users can check if a specific key is
present in the dictionary.
5. Getting a Value by Key: Users can retrieve the value associated
with a specific key.
6. Iterating Through Keys: Users can view all keys in the dictionary.
7. Iterating Through Values: Users can view all values in the
dictionary.
8. Iterating Through Key-Value Pairs: Users can view all key-value
pairs in the dictionary.
9. Getting All Keys: Users can get a list of all keys.
10. Getting All Values: Users can get a list of all values.
11. Getting All Items: Users can get a list of all key-value pairs as
tuples.
12. Merging Dictionaries: Users can merge another dictionary with
the current dictionary.
13. Clearing the Dictionary: Users can remove all entries from the
dictionary.
14. Finding the Maximum Value: Users can find the maximum value
in the dictionary.
15. Finding the Minimum Value: Users can find the minimum value in
the dictionary.
16. Exiting the Program: Users can exit the program.
Each option is presented in a menu format, and users can select the
desired operation by entering the corresponding number. The
program runs in a loop, continually presenting the menu after each
operation until the user chooses to exit by entering '0'.
Source Code
Output
Here is the expected output for each command if you run the Dictionary
Management Program:
1. Add Key-Value Pair
Enter your choice: 1
Enter key: name
Enter value: John
Key-value pair added.
2. Update Key-Value Pair
Enter your choice: 2
Enter key to update: name
Enter new value: Doe
Key-value pair updated.
3. Remove Key-Value Pair
Enter your choice: 3
Enter key to remove: name
Key removed if it existed.
4. Check if Key Exists
Enter your choice: 4
Enter key to check: name
Key exists.
5. Get Value by Key
Enter your choice: 5
Enter key to access: name
Value: John
6. Iterate Through Keys
Enter your choice: 6
Keys: ['name']
7. Iterate Through Values
Enter your choice: 7
Values: ['John']
8. Iterate Through Key-Value Pairs
Enter your choice: 8
Items:
name: John
9. Get All Keys
Enter your choice: 9
All Keys: ['name']
10. Get All Values
Enter your choice: 10
All Values: ['John']
11. Get All Items
Enter your choice: 11
All Items: [('name', 'John')]
12. Merge Dictionaries
Enter your choice: 12
Enter number of items to merge: 1
Enter key: age
Enter value: 30
Dictionaries merged.
13. Clear Dictionary
Enter your choice: 13
Dictionary cleared.
14. Find Maximum Value
Enter your choice: 14
Maximum Value: John
15. Find Minimum Value
Enter your choice: 15
Minimum Value: John
16. Exit
Enter your choice: 0
Exiting the program.
Conclusion
The Dictionary Management Program is an effective tool designed to
simplify and streamline the management of dictionaries in Python. It
provides a range of functionalities that cater to various user needs,
including:
Addition and Modification: Users can easily add new key-value
pairs or update existing ones, ensuring the dictionary remains
current and accurate.
Removal and Clearing: Users can remove specific key-value
pairs or clear the entire dictionary, providing control over the
stored data.
Search and Retrieval: Users can check if a key exists and
retrieve values efficiently, making the program useful for quick
lookups.
Iteration and Display: The program allows users to iterate
through keys, values, and key-value pairs, offering a clear view
of the dictionary's contents.
Advanced Operations: Users can merge dictionaries and find
the maximum or minimum values, enhancing the program's
versatility.
User-Friendly Interface: The menu-driven interface ensures that
all these operations are accessible and easy to navigate,
making it suitable for users of all levels of expertise.
In summary, this program provides a robust and user-friendly
solution for managing dictionary data structures, demonstrating the
practical application of Python programming concepts in real-
world scenarios.
Bibliography
1. Python Official Documentation:
o Python Software Foundation. "Python Documentation."
Available at: [Link]
o This is the official documentation provided by the
creators of Python. It covers all the basics as well as
advanced topics.
2. Python for Everybody:
o Severance, C. R. (2016). Python for Everybody: Exploring
Data in Python 3. CreateSpace Independent Publishing
Platform.
o An introductory book for learning Python with a focus on
data exploration.
3. Real Python: Python Dictionaries:
o "Python Dictionaries: A Comprehensive Guide" - Real
Python. Available at: [Link]
o This guide provides an in-depth look at Python
dictionaries, including their functionalities and usage.
4. GeeksforGeeks Python Dictionary Tutorial:
o "Python Dictionary - GeeksforGeeks." Available at:
[Link]
o GeeksforGeeks offers a comprehensive tutorial on Python
dictionaries, including various operations and methods.