Question: Write a program that repeatedly displays menu: My Phonebook 1. Find a phone number by name. 2. Add an entry. 3. Quit. Your choice: If
Write a program that repeatedly displays menu:
My Phonebook
1. Find a phone number by name.
2. Add an entry.
3. Quit.
Your choice:
If the user chooses 1, there will be prompt for the name, and either the program will display the corresponding phone number or tell that there is no such an entry.
If the user chooses 2, there will be a prompt for the name, and the program will either follow with a prompt for the phone number or tell that there is already an entry for that name.
When the user enters option from the main menu, guarding against errors of input must be used. Use $csc223/01guarding/guarding.py.
When the program is running the phone book data must be stored in a dictionary, and between the sessions (when it is not running) it must be stored in a file phonebook.dat by using the module pickle.
The project must be in a directory 01phonebook and must contain files guarding.py (given to you), phonebook.py and phonebook.dat. The .py files must have the shebang line on the top: #!//usr/bin/env python3 and they must be made executable (by the linux shell command chmod u+x.
Module guarding.py Contains functions to get standard input while guarding agains errors: getInteger(prompt) getIntegerBetween(prompt, lower, upper) To use this module, copy it to your project directory and place an import statement in your program. Import only your copy of the module, not the orginal from $csc221 -- the original is likely to be modified. To do: write functions, which prompt for an abritrary number (float or int). '''
def getInteger(prompt): while True: try: n = int(input(prompt)) break except ValueError: print("This input is not correct. Try again ...") return n
def getIntegerBetween0(prompt, lower, upper): '''getIntegerBetween0(prompt, lower, upper) getIntegerBetween0(
def getIntegerBetween(prompt, lower = None, upper = None): '''getIntegerBetween(prompt, lower, upper) getIntegerBetween(
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
