1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
larisa86 [58]
4 years ago
4

Given an integer representing a 10-digit phone number, output the area code, prefix, and line number using the format (800) 555-

1212. Ex: If the input is: 8005551212 the output is: (800) 555-1212 Hint: Use % to get the desired rightmost digits. Ex: The rightmost 2 digits of 572 is gotten by 572 % 100, which is 72. Hint: Use // to shift right by the desired amount. Ex: Shifting 572 right by 2 digits is done by 572 // 100, which yields 5. (Recall integer division discards the fraction). For simplicity, assume any part starts with a non-zero digit. So 0119998888 is not allowed.
Computers and Technology
2 answers:
ankoles [38]4 years ago
5 0

Given an integer representing a 10-digit phone number, output the area code, prefix, and line number using the format (800) 555-1212.

The examples and taken into account and the code is written.

The code for the above statement is given below :

Explanation:

phone_number = input()

if (len(phone_number)==10):

print(phone_number[0] + phone_number[1] + phone_number[2] + '-' + phone_number[3] + phone_number[4] + phone_number[ 5] + '-' + phone_number[6] + phone_number[7] + phone_number[8] + phone_number[9])

else:

print('invalid phone number')

The number is taken as the input. Then, the length is checked.

If the number starts with 0 it is not allowed.

andrey2020 [161]4 years ago
5 0

Answer:

input: 8005551212

phone_number = int(input())

area_code = phone_number // 10000000

prefix = (phone_number // 10000) % 1000

line_number = phone_number % 10000

print(f'({area_code}) {prefix}-{line_number}')

Explanation:

#input data

8005551212

#define phone number to input data

phone_number = int(input())

#logic to find area_code, prefix, and line_number

area_code = phone_number // 10000000

prefix = (phone_number // 10000) % 1000

line_number = phone_number % 10000

#f-strings(format strings) are a shorter way of doing str.format() calls.

print(f'({area_code}) {prefix}-{line_number}')

You might be interested in
What is the full form of com​
nignag [31]

The answer is:

Commercial

3 0
3 years ago
In a complex system, many subsystems interact with one another. How do these systems interact in terms of inputs and outputs?
Artemon [7]

Answer:

I think in there transmission you know inputs into ports like for their own

Explanation:

likeslike Spanish and is obviously inputs and outputs their portsinto the portsdifferent ports you know

4 0
3 years ago
The safest action to take if someone claiming to be from your banks calls you to ask for account information is to
aalyn [17]
<h2>Answer:</h2>

<u>The correct option is</u><u> (B) hang up and call back using the banks official phone number</u>

<h2>Explanation:</h2>

There are a lot of cases where people pretend to call from the banks where the receivers have the account. The caller tries to take the information from the receiver and pretends to be the bank official. If there is any doubt then the receiver should hang up the call and call back the official number of the bank to confirm that whether somebody has called from the bank to get the information.

8 0
3 years ago
Read 2 more answers
Which of the following describes a Trojan horse?
HACTEHA [7]

Answer:

the answer is

c. Trojan horses enter a secure space, while an infected file proceeds to be downloaded and run.

7 0
3 years ago
__________ is a term used to indicate any unwanted event that takes place outside normal daily security operations. This type of
Delvig [45]
The answer is “a security event”
6 0
3 years ago
Other questions:
  • Data hiding, which means that critical data stored inside the object is protected from code outside the object, is accomplished
    14·2 answers
  • Select the best word or phrase to complete each sentence Jobs that require you to use your v are typically rewarding Individuals
    12·1 answer
  • Maria is comparing her history project's second-place award to her classmate's first-place award. She starts planning how to win
    9·2 answers
  • What might happen if dispatchable threads were removed from the software hierarchy? A. Requests from the mouse would be ignored.
    9·1 answer
  • Which of the following is NOT areserved word in Java?intpublicstaticnum
    9·1 answer
  • When an object is acted on by unbalanced forces, the object will always
    11·1 answer
  • Old systems can be useful when designing new computer software.<br> True or False
    7·2 answers
  • Your friends are having difficulties with their computer setups. Can you suggest a way to help each friend?
    5·1 answer
  • Hey everyone please let my friends answer please?????? .
    12·2 answers
  • What is the total number of time zones that can be configured to show by default in a calendar in Outlook 2016?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!