Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use python For the following, all functions must have a proper docstring and annotations. Use try/except and in case of an error print a

Please use python

image text in transcribed

For the following, all functions must have a proper docstring and annotations. Use try/except and in case of an error print a user-friendly message to the terminal and raise or re-raise the exception. For this problem we will develop a contact list, similar to what is on smartphones. The contact list data structure is a list of tuples with the following format (name, nickname, phone). For instance, a sample contact list could be [("Beyonce Knowles", "bey", "561-1234321"), ("Cardi B", "Belcalis", "305-4399521"), ("Earl Simmons", "DMX", "305-1010101")). The contact list must be stored in a Python list of tuples, as above, always sorted alphabetically on the name field. An empty contact list is represented by the empty list []. For your solution to get any credit do NOT use dictionaries. a) Write a function that adds a contact to a contact list. If the contact name existed before in the list then it will be changed to the new entry and the function returns False. Otherwise, the function should return True. b) Write a function that removes a contact from a contact list. If the contact name existed before in the list then the function returns True. Otherwise, the function should return False. c) Write a function that finds a contact tuple from a contact list by passing the contact name or contact nickname. Use default parameter values to deal with this choice. The function returns the tuple if the contact is found and returns None otherwise. d) Write a function that saves a contact list to a.CSV file. The function takes as parameter the file name. The CSV file format must have name, nickname, phones on a line for each contact in the list. e) Write a function that reads a contact list from a .CSV file with the format described for part d). The function takes as parameter the file name and returns the contact list object (... sorted alphabetically). f) Write a main function that tests all the functions above

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

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

10. Are you a. a leader? b. a follower? _______

Answered: 1 week ago