subject
Computers and Technology, 08.03.2021 19:20 lin550

Given an integer representing a 10-digit phone number, output the area code, prefix, and line number, separated by hyphens. 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 are 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 that integer division discards the fraction).
For simplicity, assume any part starts with a non-zero digit. So 999-011-9999 is not allowed.
LAB: Phone number breakdown 0/100
1 phone_number = int(input)
2
3 num_one = s[:3]
4 num_two = s[3:6]
5 num_three = s[6:]
6
7 final_number = '('+num_one+')'+num_two+'-' +num_three
8 print = final_number

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:00, lexhorton2002
The great length of north america causes the climate to be varied. true false
Answers: 2
image
Computers and Technology, 22.06.2019 15:00, nika0001
When designing content as part of your content marketing strategy, what does the "think" stage represent in the "see, think, do, care" framework?
Answers: 3
image
Computers and Technology, 22.06.2019 22:20, kaiyerecampbell95
Pp 4.1 design and implement a class called sphere that contains instance data that represents the sphere’s diameter. define the sphere constructor to accept and initialize the diameter and include getter and setter methods for the diameter. include methods that calculate and return the volume and surface area of the sphere (see pp 3.5 for the formulas). include a tostring method that returns a one-line description of the sphere. create a driver class called multisphere, whose main method instantiates and updates several sphere objects.
Answers: 1
image
Computers and Technology, 24.06.2019 03:00, 2020IRodriguez385
With editing, word automatically displays a paste options button near the pasted or moved text. a. cut-and-paste b. drag-and-drop c. inline d. copy-and-carry
Answers: 1
You know the right answer?
Given an integer representing a 10-digit phone number, output the area code, prefix, and line number...

Questions in other subjects:

Konu
Mathematics, 25.05.2020 02:58