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 10:30
Auniversity wants to install a client-server network. which feature do you think is important for them as they set up the network? sending email blocking multiple people to use the same file low security low set up cost limited access to files
Answers: 1
question
Computers and Technology, 23.06.2019 13:00
Which one of the following voltages should never be measured directly with a vom? a. 1200 v b. 500 v c. 800 v d. 100v
Answers: 2
question
Computers and Technology, 24.06.2019 23:30
True or false when a host gets an ip address from a dhcp server it is said to be configured manually
Answers: 1
question
Computers and Technology, 25.06.2019 12:10
Create a function called quadform( ) that takes as input the coefficients of the quadratic equation (a,b,c) and returns the two distinct real roots (x1,x2) as output, if they exist. in addition, the function returns a message (flag) that informs the user if an error occurred when trying to find two distinct real roots. the possible errors are: (1) "only one root is found"; (2) "imaginary roots are found"; (3) "any value of x is a solution"; (4) "no zeroes exist." if no errors occur, then flag should be "no errors".
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
Mathematics, 11.10.2019 04:00
question
Biology, 11.10.2019 04:00
Questions on the website: 13722363