Question: Using Python, create a Python module named phoney for cleaning and searching a list of telephone numbers. In North America, phone numbers consist of three
Using Python, create a Python module named phoney for cleaning and searching a list of telephone numbers.
In North America, phone numbers consist of three parts: XXXYYYZZZZ where:
XXX: the area code
YYY: the exchange
ZZZZ: the station codeline of the individual
Requirements
You must use at least one list comprehension in your phoney module 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.
Starter Code
Starter code is provided to you in index.py and phoney.py
A sample CSV file with phone numbers is included in phonenumberssample.csv YOU MUST DOWNLOAD AND USE A COMPLETE phonenumbers.csv FILE USING INSTRUCTIONS IN THE ASSIGNMENT.
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 you 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.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
