Explore Westonci.ca, the top Q&A platform where your questions are answered by professionals and enthusiasts alike. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently. Get quick and reliable solutions to your questions from a community of experienced experts on our platform.
Sagot :
Answer:
In Python:
phonenum = int(input("10 digit phone number: "))
last4 = phonenum%10000
phonenum//=10000
mid3 = phonenum%1000
phonenum = phonenum//1000
newnum = str(phonenum)+"-"+str(mid3)+"-"+str(last4)
print("New: "+str(newnum))
Explanation:
This prompts the user for phone number
phonenum = int(input("10 digit phone number: "))
This gets the last 4 of the phone number using % operator
last4 = phonenum%10000
This shifts the phone number by 4 digit right
phonenum//=10000
This gets the middle 3 of the phone number using % operator
mid3 = phonenum%1000
This shifts the phone number by 3 digit right
phonenum = phonenum//1000
This generates the new phone number which includes the area code...
newnum = str(phonenum)+"-"+str(mid3)+"-"+str(last4)
This prints the formatted phone number
print("New: "+str(newnum))
Thank you for choosing our service. We're dedicated to providing the best answers for all your questions. Visit us again. Thank you for choosing our platform. We're dedicated to providing the best answers for all your questions. Visit us again. Find reliable answers at Westonci.ca. Visit us again for the latest updates and expert advice.