Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 . You must use at least one list comprehension in your phoney module ( but you may use more than one ) 2 .
You must use at least one list comprehension in your phoney module but you may use more than one
Your phoney module should include the typecode hinting that specifies the expected data type for your function arguments.
Each function in your phoney module must also include a docstring that provides a brief overview of its functionality.
Getting Started
Create a new directory named phoneymodulev inside your local root folder for this course.
Write your code in the phoney.py and index.py files inside the phoneymodulev directory.
You should be able to run your program by typing python index.py from the command line while you are in your phoneymodulev directory.
Instructions
Functions in the phoney Module:
cleanphonenumbers: Accepts a list of phone numbers and returns a list of phone numbers that contain precisely digits. It removes any special characters from the numbers parenthesis hypens and removes any number that is not precisely characters long
findnumber: Accepts a list of "clean" phone numbers and a search term. Searches the entire list for an exact match of the search term. Returns a string that reports the number of times the search term is found in the list.
findareacode: Accepts a list of "clean" phone numbers and a search term. Searches the first three digits of each element in the list for an exact match of the search term. Returns a string that reports the number of times the search term is found in the list.
findexchange: Accepts a list of "clean" phone numbers and a search term. Searches the digits at indices of each element in the list for an exact match of the search term. Returns a string that reports the number of times the search term is found in the list.
Instructions for index.py
Create a function named presentmenu that presents a menu of options to the user and continues to request input until valid input is found. The function then returns the selection.
Menu options should include:
F: Search for full phone number
A: Search for area code
E: Search for exchange
X: Exit the program
In the main function:
Import the phonenumbers.csv file and read the contents into a dimensional list
Pass the list of phone numbers to phoney.cleanphonenumbers to obtain a list of "clean" phone numbers
Report the results of the cleaning function to the user
Start a loop
o Ask the user for a menu selection by calling presentmenu
o If the user enters X quit the program
o If the user chooses another option, ask the user to input a search term
Invoke the appropriate function in the phoney module and pass it the list of clean phone numbers and the user's search term
Report the results of the search function
o Restart the loop ask the user for a new menu selection
Hints
Although we think of phone numbers as "numbers", your program will work much more smoothly if you treat them as strings that contain digits not "numbers"
Submission Instructions
To submit, zip the following files and attach A SINGLE ZIP FILE to Canvas:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started