In Python For this question, ONLY describe about half a page of the input and half a page of the output of the code below. It must be a very detailed description of the input and output. NO need to code! In your own words, describe the problem including input and output. In your own words, Describe the major steps for solving the problem. Name and Email Addresses "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."
In Python
For this question, ONLY describe about half a page of the input and half a page of the output of the code below. It must be a very detailed description of the input and output.
NO need to code!
- In your own words, describe the problem including input and output.
- In your own words, Describe the major steps for solving the problem.
Name and Email Addresses
"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."
ONLY describe the input and the output of the code below. It must be a very detailed description of the input code and output typed below.
Code:
def menu():
print("\nMenu")
print("----------------------------------------")
print("1. Look up an email address")
print("2. Add a new name and email address")
print("3. Change an existing email address")
print("4. Delete a name and email address")
print("5. Quit the program")
print()
def look_email(m):
name=input("Enter a name:")
if name in m:
print("Name: ",name)
print("Email: ",m[name])
else:
print("The specified name was not found")
def add_new(m):
name=input("Enter name: ")
email=input("Enter email address: ")
if name in m:
print("That name already exists")
else:
m[name]=email
print("Name and address have been added")
return m
def update_mail(m):
name=input("Enter name: ")
email=input("Enter the new address: ")
if name in m:
m[name]=email
print("Information updated")
return m
def delete_record(m):
name=input("Enter name: ")
if name in m:
del m[name]
print("Information deleted")
return m
else:
print("The specified name was not found")
def main():
data ={}
while True:
menu()
n=int(input("Enter your choice: "))
if n==1:
look_email(data)
elif n==2:
add_new(data)
elif n==3:
update_mail(data)
elif n==4:
delete_record(data)
elif n==5:
print("Information saved")
break
if __name__ == "__main__":
main()
Output:
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
>>>
Upvote for describing in one page the input and output of the program one page. Thank you.
Step by step
Solved in 3 steps with 7 images