Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assignment: phoney Module, v . 1 CIT 3 0 9 0 0 What s the Big Idea? Using Python, create a Python module named phoney
Assignment: phoney Module, v
CIT
Whats the Big Idea?
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
Starter Code
Starter code is provided to you in a repository on GitHub.
To use this code, click on the index.py and phoney.py files. Then click the Raw button on the toolbar at the top right.
This is a recommended structure for this application, but you may choose your own.
A file named phonenumberssample.csv is included for development and testing, but you should use a randomized data set that contains records and is provided for you. Instructions to obtain this data are on Canvas.
Requirements
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:
phoney.py
index.py
phonenumbers.csv NOT the sample CSV provided to you
Rubric
Requirement Points Available
Program displays a menu and accepts user input
Phoney module has a function to properly clean phone numbers
User can search for phone numbers
User can search for area codes and exchanges
Total:
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