Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**I need help with #2 the optional function part. ** Name your script _lookup.py The program should have 3 functions: 1. An input function to

**I need help with #2 the optional function part. **

Name your script _lookup.py The program should have 3 functions: 1. An input function to read the comma-separated addresses from file address.txt into a dictionary. The function should: a. Take no arguments. b. Use the first field (first and last name) as the dictionary key. The dictionary value should be the entire line. (I suggest you strip off the newline from each line right after you read it in.) c. When you open the file for reading, use a tryexcept to detect if the file open fails. If so, print an error end exit the program with an exit code of 1. d. return the dictionary as the return value of the function. 2. A function to format and display the output. Use whatever arguments are appropriate but at least one of them should determine if the function should display just the phone number or the address information. Make this argument an optional argument with the default being to print just the phone number. The address output should be formatted neatly, similar to the following: Street: 285 Andover Lane City: Pompano Beach State: FL Zip Code: 33060 3. A main() function that: a. Calls the input function to populate the address/phone dictionary. b. Ask the user if they want to lookup phone numbers or addresses, and do so in a loop until they select an appropriate option. c. Repeatedly loop, asking for a valid first and last name, and calling the function to format and display the output. If the name does not exist, an appropriate message should be displayed and the user prompted again. d. The program should end when the user enters a blank or empty line.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

Know how productivity improvements impact quality and value.

Answered: 1 week ago

Question

Recommend the key methods to improve service productivity.

Answered: 1 week ago