asked 36.8k views
4 votes
Program Specifications Write a program to input a phone number and output a phone directory with five international numbers. Phone numbers are divided into four parts: 1) country code, 2) area code, 3) prefix, and 4) line number. For example, a phone number in the United States is +1 (555) 123-4567. Note: this program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress. Step 1 (2 pts). Read from input an area code, prefix, and line number (integers). Output the directory heading (two lines). Insert two blank spaces between Country and Phone and the horizontal line is created with dashes (not underscores). Output a phone number for the United States with country code +1 using proper format. Submit for grading to confirm 2 tests pass. Ex: If the input is: 555


4572345

The output is: Country −−−−−−
U.S. ​
Phone Number −−−−−−−−−−
+1 (555) 457−2345

Step 2 (2 pts). Output a phone number for Brazil with country code +55 and add 100 to the prefix. The prefix variable should not change. Instead, add 100 to the prefix within the print statement. For example, print (f") \{prefixNum +100}−"). Submit for grading to confirm 3 tests pass. Ex: If the input is: 555

457

2345

The output is: Step 3 ( 2 pts). Output a phone number for Croatia with country code +385 and add 50 to the line number. Output a phone number for Egypt with country code +20 and add 30 to the area code. The variables should not change. Instead, add values within the print statement as in Step 2. Submit for grading to confirm 4 tests pass. Ex: If the input is: 5559296453 The output is: Step 4 ( 2 pts). Output a phone number for France with country code +33 and swap the area code with the prefix. Submit for grading to confirm all tests pass. Ex: If the input is: 5559296453 The output is: \begin{tabular}l LAB & 4.5.1: LAB ⋆
: Program: Phone directory \\ ACTIVITY & 4. \end{tabular} 4/10 main.py Load default template... 1 \# Type your code here. 2 print("Country Phone Number") 3 print("..... -.........") 4 print("U.5. +1 (555) 457−2345 ") 5 print("Brazil +55 (555) 1029−6453 ′′
) 6 print("Croatia +385 (555)929-6503") 7 print ("Egypt +20 (585)929-6453") 8 print("France +33 (929)555-6453")

asked
User Manesioz
by
8.4k points

2 Answers

5 votes

Final answer:

This program is designed to input a phone number and output a phone directory with international numbers, incrementally completing each step with different modifications.

Step-by-step explanation:

This program is designed to take input of a phone number and output a phone directory with international numbers. Each phone number is divided into four parts: country code, area code, prefix, and line number. The program completes each step incrementally, starting with the United States phone number and adding additional countries and modifications in each step.

In Step 1, the program reads the area code, prefix, and line number from the input. It then outputs the directory heading and the United States phone number using the proper formatting.

In Step 2, the program outputs a phone number for Brazil with the country code +55 and adds 100 to the prefix.

In Step 3, the program outputs phone numbers for Croatia with the country code +385 and adds 50 to the line number, and for Egypt with the country code +20 and adds 30 to the area code.

In Step 4, the program outputs a phone number for France with the country code +33 and swaps the area code with the prefix.

answered
User Eugene Mamin
by
7.5k points
6 votes

A Python program that takes a phone number as input and generates five international phone numbers with varying country codes:

The Code

def generate_phone_directory(phone_number):

country_code = phone_number[:3]

area_code = phone_number[3:6]

prefix = phone_number[6:9]

line_number = phone_number[9:]

for i in range(5):

print(f"Country Code: {country_code}-{i + 1}")

print(f"

answered
User Inzzz
by
8.2k points

No related questions found