Answered step by step
Verified Expert Solution
Link Copied!

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.1
CIT 30900
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: XXX-YYY-ZZZZ where:
XXX: the area code
YYY: the exchange
ZZZZ: the station code/line 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 phone_numbers_sample.csv is included for development and testing, but you should use a randomized data set that contains 1,000 records and is provided for you. Instructions to obtain this data are on Canvas.
Requirements
1. You must use at least one list comprehension in your phoney module (but you may use more than one)
2. Your phoney module should include the type/code hinting that specifies the expected data type for your function arguments.
3. Each function in your phoney module must also include a docstring that provides a brief overview of its functionality.
Getting Started
1. Create a new directory named phoney_module_v1 inside your local root folder for this course.
2. Write your code in the phoney.py and index.py files inside the phoney_module_v1 directory.
3. You should be able to run your program by typing python index.py from the command line while you are in your phoney_module_v1 directory.
Instructions
Functions in the phoney Module:
1. clean_phone_numbers(): Accepts a list of phone numbers and returns a list of phone numbers that contain precisely 10 digits. It removes any special characters from the numbers (parenthesis, hypens) and removes any number that is not precisely 10 characters long
2. find_number(): 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.
3. find_areacode(): 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.
4. find_exchange(): Accepts a list of "clean" phone numbers and a search term. Searches the digits at indices 3-5 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
1. Create a function named present_menu() 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
2. In the main() function:
Import the phone_numbers.csv file and read the contents into a 1-dimensional list
Pass the list of phone numbers to phoney.clean_phone_numbers 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 present_menu()
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:
1. phoney.py
2. index.py
3. phone_numbers.csv (NOT the sample CSV provided to you)
Rubric
Requirement Points Available
Program displays a menu and accepts user input 5
Phoney module has a function to properly clean phone numbers 10
User can search for phone numbers 5
User can search for area codes and exchanges 5
Total: 25
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

3. Define the attributions we use to explain behavior

Answered: 1 week ago