In Python Please check the pictures first. Write a program that keeps names and email addresses in a dictionary as key-value pairs. The program should display a menu that lets the user look up a person’s email address, add a new name and email address, change an existing email address, and delete an existing name and email address. The program should save the data stored in a dictionary to a file when the user exits the program. Each time the program starts, it should retrieve the data from the file and store it in a dictionary. You Must create and use at least 5 meaningful functions. A function to display a menu A function to look up a person’s email address A function to add a new name and email address A function to change an email address A function to delete a name and email address. Check the Your program should check user input; for example, if the user wants to delete a name that does not exist in the dictionary, you should print something like: the name is not in the database. A sample one run is shown below. Hints for how the format of the program HAVE to be written : a function to print the menu a function to look up an email address (person) a function to add a name and email (person, email) a function to change email (person) a function to delete a name and email address (person) flag = -1 read data from a file and store it in a dictionary – name email get user option and store it in variable flag while flag ! = 5 multi – way selection to process user option (5 options) if flag == 1 if flag == 2 if flag == 3 if flag == 4 if flag == 5 call function menu again get user option again write the data in the dictionary in a file This is the Required Output example: Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program Enter your choice: 2 Enter name: John Enter email address: John@yahoo.com That name already exists Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program Enter your choice: 2 Enter name: Jack Enter email address: Jack@yahoo.com Name and address have been added Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program Enter your choice: 1 Enter a name: Sam The specified name was not found Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program Enter your choice: 1 Enter a name: Jack Name: Jack Email: Jack@yahoo.com Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program Enter your choice: 3 Enter name: John Enter the new address: John@wayne.edu Information updated Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program Enter your choice: 1 Enter a name: John Name: John Email: John@wayne.edu Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program Enter your choice: 4 Enter name: Sam The specified name was not found Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program Enter your choice: 4 Enter name: Jack Information deleted Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program Enter your choice: 1 Enter a name: Jack The specified name was not found Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program Enter your choice: 5 Information saved >>> Please check the pictures and fix the code. Upvote for following the required steps and working code. Thank You.
In Python
Please check the pictures first.
Write a program that keeps names and email addresses in a dictionary as key-value pairs.
The program should display a menu that lets the user look up a person’s email address, add a new name and email address, change an existing email address, and delete an existing name and email address. The program should save the data stored in a dictionary to a file when the user exits the program. Each time the program starts, it should retrieve the data from the file and store it in a dictionary.
You Must create and use at least 5 meaningful functions.
- A function to display a menu
- A function to look up a person’s email address
- A function to add a new name and email address
- A function to change an email address
- A function to delete a name and email address.
Check the Your program should check user input; for example, if the user wants to delete a name that does not exist in the dictionary, you should print something like: the name is not in the
Hints for how the format of the program HAVE to be written :
a function to print the menu
a function to look up an email address (person)
a function to add a name and email (person, email)
a function to change email (person)
a function to delete a name and email address (person)
flag = -1
read data from a file and store it in a dictionary – name email
get user option and store it in variable flag
while flag ! = 5
multi – way selection to process user option (5 options)
if flag == 1
if flag == 2
if flag == 3
if flag == 4
if flag == 5
call function menu again
get user option again
write the data in the dictionary in a file
This is the Required Output example:
Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program
Enter your choice: 2 Enter name: John Enter email address: John@yahoo.com That name already exists
Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program
Enter your choice: 2 Enter name: Jack Enter email address: Jack@yahoo.com Name and address have been added
Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program
Enter your choice: 1 Enter a name: Sam The specified name was not found
Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program
Enter your choice: 1 Enter a name: Jack Name: Jack Email: Jack@yahoo.com
Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program
Enter your choice: 3 Enter name: John Enter the new address: John@wayne.edu Information updated
Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program
Enter your choice: 1 Enter a name: John Name: John Email: John@wayne.edu
Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program
Enter your choice: 4 Enter name: Sam The specified name was not found
Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program
Enter your choice: 4 Enter name: Jack Information deleted
Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program
Enter your choice: 1 Enter a name: Jack The specified name was not found
Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program
Enter your choice: 5 Information saved >>> |
Please check the pictures and fix the code.
Upvote for following the required steps and working code. Thank You.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps