In this assignment you will write functions, use functions and their appropriate parameters, and use random...
Fantastic news! We've located the answer you've been seeking!
Question:
Transcribed Image Text:
In this assignment you will write functions, use functions and their appropriate parameters, and use random numbers generated by the computer. Background Phone numbers are everywhere. Did you know they have a set of rules that are used to define each number? This is how the switching system knows if you forgot to include an area code and how to direct calls where they need to go. Phone numbers are made up of three parts: • Area Code (3 digits)  This is the code used by the system to decide which switching offices to use (well in the old days when phone numbers were tied to geographic regions). Central Office code (3 digits)  This is the code used to decided how to switch the number to different regions withing the switching office's control (well again in the old days). The first two digits were originally based on the office's name. Which is why phones have letters tied to the numbers. • • Line number (4 digits)  This is your unique number to your phone line that you have. In fact, in the really old days, you would only need these 4 digits to call a line. And even in the early days, a phone line number would be for a whole street and everyone on the same street (45 houses) would share the same line number. A phone number is created by placing all of the parts together area code first, office code next, and finally the line number. However just having all of the digits together makes it difficult to read. Such as: 2082823215 So, we tend to give formatting to the number to make it easier to read such as parenthesis around the area code and placing a hyphen between the office and line numbers like this: (208) 2823215 In case you might be wondering why phone numbers are the length they are (7 digits without the area code) this is because your shortterm memory can only store 59 object (or in this case digits). So, 7 was safely in the middle. This was intended so that a person could hear a phone number and remember it easily. Of course, now our phones do it so there is no reason to remember phone numbers. In fact, most people now days cannot remember more than just a few phone numbers. Now a days, phone numbers follow the same pattern even though the numbers are no longer tied to a geographic region. Which comes from people moving across states and keeping their numbers. Instructions You will be creating a program that will use random numbers to create a set of possible phone numbers. To use the application, the user will enter a number of phone numbers to print. Then using pseudo random number generation available using the random module, the program will display to the user a specified number of phone numbers. Create a Python script: 1. Name the script phone_maker.py 2. Write code to create the following functionality a. Import the random library b. Create a function named get_number_to_generate which accepts nothing (has no parameters) and prompts the user for the number of phone numbers to generate. This function needs to return an integer representation of the user's response. c. Create a function named get_line_number which accepts nothing (no parameters) and returns an integer representation of a line number in the appropriate range. i. You must use the randrange function. 1. Do not use the randint function. ii. The values must be between 0 and 9999 (inclusive). d. Create a function named get_area_code which accepts an integer of the starting number of the area code and returns an integer representation of an area code in the appropriate range. i. You must use the randrange function. 1. Do not use the randint function. ii. The area code must follow the following rules: 1. The first digit of the area code must be the number passed in the parameter. a. If the parameter contains a 2, (parameter) Minimum Maximum value given value value NOON19 b. See the table for more examples; 3 5 6 9 2 300 500 600 then the values could possibly be 217, 208, or 200 2. The last two digits must fall between 00 and 19 (inclusive). 3. The area code must be a 3digit number. a. Assuming N is the given number, the acceptable values are: 900 200 Note: Technically any area code ending in 11 would be illegal, but we will ignore this rule. For example: 911 is an acceptable area code in our rules. 319 519 619 919 219 e. Create a function named get_office_code which accepts an integer of the starting number of the office code and returns an integer representation of an office code in the appropriate range. i. You must use the randrange function. 1. Do not use the randint function. The office code must follow the following rules: 1. The first digit of the office code must be the number passed in the parameter. a. If the parameter contains a 2, then the values could possibly be 257, 228, or 260 2. The last two digits must fall between 20 and 99 (inclusive). The office code must be a 3digit number. 3. (parameter) value given 3 5 6 9 2 Hints: Minimum value 320 520 620 For example: a. Assuming N is the given number, the acceptable values are: N20N99 b. See the table for more examples; . 920 220 f. For each number that the user requested, you will need to call each function appropriately and as needed to finish the code. iii. Calling the get_line_number function, get the value for the line number. iv. Then print the phone number from these three values. v. The number should be in the following format: (area_code) office_codeline_number i. Create a random number from 29 (inclusive) and using the get_area_code function, get and store the area code of the number. 1. 000199 are reserved for toll numbers and system codes. ii. Create a different random number from 29 (inclusive) and using the get_office_code function, get and store the office code of the number. (208) 2823215 (916) 7372592 Maximum value 399 599 699 999 299 You can use the format function to specify how many digits am integer will fill. Consult the slides from week 1 for formatting with padding. vi. You do not have to match my format, but the output should be nicely formatted. Example outputs: How many phone numbers should I show? 3 Here are the 3 random phone numbers. (918) 3590982 (810) 6730134 (204) 5410475 How many phone numbers should I show? 2 Here are the 2 random phone numbers. (418) 9366061 (818) 2970215 How many phone numbers should I show? 5 Here are the 5 random phone numbers. (310) 8589028 (304) 9760660 (200) 4954661 (508) 5307307 (509) 4662141 Tips: You may find it useful, for testing purposes, to temporarily assign a seed at the start of your program. If you do this, the values will not change and you can check for patterns. Use the following code to do this: random.seed (3) If you use the seed of 3, and you only get random area codes with a starting digit of 2, you should get the following: 207, 218, 217, 204, 211, 219, 215, etc. If you use the seed of 3, and you only get random office codes with a starting digit of 2, you should get the following: 250, 295, 289, 236, 267, 297, 280, etc. If you use the seed of 3, and you only get a random line numbers, you should get the following: 3898, 9709, 8916, 2136, 6061, 9894, 7766, etc. Now if you use the seed of 3, and you a random hour then a random minute, you should get the following: 07:37, 17:08, 11:58, 19:30 Note: Technically any area code ending in 11 would be illegal, but we will ignore this rule. For example: (911) 9119111 is an acceptable number in our rules. Scoring 1. 5% Compiles without errors 2. 3%  Imports the correct module at the top of the file. 3. 7%  Has a function named get_number_to_generate and has no parameters. Prompts the user and returns the correct data type. 4. 17%  Has a function named get_area_code() and has correct parameters. correctly get area code using random and parameter; uses the randrange function correctly; returns the correct data type. 5. 17%  Has a function named get_office_code() and has correct parameters. correctly get office code using random and parameter; uses the randrange function correctly; returns the correct data type. 6. 15%  Has a function named get_line_number() and has no parameters. correctly get line using random; uses the randrange function correctly; returns the correct data type. 6%  Generates random numbers for start of area and office codes 7. 8. 15%  Correctly generates a list of phone numbers from functions. calls the appropriate function and the correct way. 9. 5%  Presents list back to the user in an appropriate way. 10. 10%  Meaningful comments: This includes your header block with your name at the top. This includes proper function comments.
Expert Answer:
Answer rating: 100% (QA)
Based on the assignment details provided here is a sample Python script that you can use as phone maker py This script includes the necessary function... View the full answer
Related Book For
Modern Database Management
ISBN: 9780133544619
12th edition
Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi
Posted Date:
Students also viewed these programming questions

Introduction In this assignment you will write a small C program to read the coefficients of a third degree equation, and use a numerical integration method for calculating a numerical value of a...

In this Assignment you examine the target customer using your CSR Tool Belt including the life stages of the targeted customer. The better you are at understanding who the targeted customer is, the...

In this assignment you are going to prepare payroll accounting entries, complete payroll records, and prepare payroll tax returns for a Company that started operations on October 1 of the current...

Refer to the Webers Data Set above. 1. Compute the direct materials efficiency variance for onion, mustard, and ketchup. 2. As a manager, what would you learn from the variances and supporting data?...

Assume that x is a binomial random variable with n = 1,000 and p = .50. Find each of the following probabilities: a. P(x > 500) b. P(490 x < 500) c. P(x > 550)

Assume the propagation delay in a broadcast network is 5 s and the frame transmission time is 10 s. a. How long does it take for the first bit to reach the destination? b. How long does it take for...

A register cell is to be designed for register B, which has the following register transfers: Share the combinational logic between the two transfers as much as possible. SO: BB+ A S1: B A + 1

Stock in Jaybird Corporation (555 Industry Lane, Pueblo, CO 81001) is held equally by Vera, Wade, and Wes. Jaybird seeks additional capital in the amount of $900,000 to construct a building. Vera,...

3.1. Perform the following base conversions using subtraction or divisionremainder: [3 X 4 Marks] 3.1.1. 54310 = 3.1.2. 75010 = 3.1.3. 42010 = 16 8

The Sun Theater, owned by Ha JiWon, will begin operations in March. The Sun will be unique in that it will show only triple features of sequential theme movies. As of March 1, the ledger of Sun...

4. A 10year bond of a firm in financial distress has a coupon rate of 12% and is selling at $900 (face value is $1,000). The firm is renegotiating its debt and the bondholders have agreed to cut...

When is it recommended to use Quick Rollback? Select the multiple correct answers A. In case of an application error B. If a user accidentally deleted a file on the VM guest OS C. If the problem...

What is Habeas Corpus? Explain the rights of individuals under community supervision. What are the grounds for the revocation of probation or parole? What is the history and current function of the...

The following circuit is the equivalent circuit of a difference amplifier in terms of difference and common mode voltage sources with an imbalance bridge model. a) Please find the Vo as a function of...

Yara a four and half (4 ) year old girl is about to commence primary school (1st yr. kindergarten) in the new year. Her older brother Jamal has been going to the same school for the last 2 years....

Evaluate the overall implications the change had on interdepartmental collaboration of tesla. In your opinion, how well did the leaders of tesla respond and prepare for the change? What worked and...

1. Which of the following comparisons is NOT correct? O a. Prophasechromosomes appear O b. Telophasespindle appears O C. Anaphasedaughter chromosomes move toward the poles O d....

Write a paper about medication error system 2016.

The Pine Valley databases for this textbook (one small version illustrated in queries throughout the text and a larger version) are available to your instructor to download from the text's Web site....

Consider the two ER diagrams in Figure 225, which represent a database of community service agencies and volunteers in two different cities (A and B). For each of the following three questions,...

Determine the relationships among the four relations in Figure 717. List primary keys for each relation and any foreign keys necessary to establish the relationships and maintain referential...

Sketch a graph of pressure versus inverse volume, assuming temperature is constant. Label the vertical axis P and the horizontal axis 1/V.

Distinguish between a real gas and an ideal gas.

State five characteristics of an ideal gas according to the kinetic theory.
Question Categories