subject

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.
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: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:30
Why would a programmer use the logical operator and in an if statement? a: when an action is to be taken that requires both conditions to be falseb: when an action is to be taken that requires both conditions to be truec: when an action is to be taken that requires the first condition to be falsed: when an action is to be taken that requires the second condition to be truei took the test and the answer is b.
Answers: 3
question
Computers and Technology, 22.06.2019 18:10
Assume that to_the_power_of is a function that expects two int parameters and returns the value of the first parameter raised to the power of the second parameter. write a statement that calls to_the_power_of to compute the value of cube_side raised to the power of 3 and that associates this value with cube_volume.
Answers: 1
question
Computers and Technology, 22.06.2019 21:00
So im doing this school challenge and the teachers said whats the average text a student gets a day so i need to get about 20 in a day but dont know how can you guys 2163371293
Answers: 2
question
Computers and Technology, 23.06.2019 04:31
Selling a product through an electronic medium is
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
question
Biology, 06.09.2020 01:01
question
Mathematics, 06.09.2020 01:01
question
Mathematics, 06.09.2020 01:01
Questions on the website: 13722361