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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 23:00
Suppose s, t, and w are strings that have already been created inside main. write a statement or statements, to be added to main, that will determine if the lengths of the three strings are in order by length, smallest to largest. that is, your code should determine if s is strictly shorter than t, and if t is strictly shorter than w. if these conditions hold your code should print (the boolean value) true. if not, your code should print false. (strictly means: no ties) example: if s, t, and w are "cat", "hats", and "skies" your code should print true - their lengths are 3-4-5; but if s, t, and w are "cats" "shirt", and "trust", then print false - their lengths are 4-5-5 enter your code in the box below
Answers: 2
question
Computers and Technology, 23.06.2019 02:30
Rafael needs to add a title row to a table that he has inserted in word. what should he do? use the alignment options. use the merge and center option for all the cells in the top row. use the merge and center option on the first two cells in the top row. none of the above
Answers: 3
question
Computers and Technology, 23.06.2019 09:00
Which company provides a crowdsourcing platform for corporate research and development? a: mtruk b: wiki answers c: mediawiki d: innocentive
Answers: 2
question
Computers and Technology, 23.06.2019 13:10
What is domain name system (dns)? allows dynamic ip address allocation so users do not have to have a preconfigured ip address to use the network converts ip addresses into domains, or identifying labels that use a variety of recognizable naming conventions the efficient coexistence of telephone, video, and data communication within a single network, offering convenience and flexibility not possible with separate infrastructures the integration of communication channels into a single service
Answers: 2
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, 04.05.2021 21:40
question
Chemistry, 04.05.2021 21:40
Questions on the website: 13722363