Westonci.ca is the Q&A platform that connects you with experts who provide accurate and detailed answers. Get quick and reliable solutions to your questions from a community of experienced professionals on our platform. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields 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))
Visit us again for up-to-date and reliable answers. We're always ready to assist you with your informational needs. We appreciate your time. Please come back anytime for the latest information and answers to your questions. Thank you for visiting Westonci.ca, your go-to source for reliable answers. Come back soon for more expert insights.