I need help with creating the following program using Python 3.2. Also need to f
ID: 3538355 • Letter: I
Question
I need help with creating the following program using Python 3.2.Also need to follow the following requirements:
Main() to control logic Use loop to examine each character User proper string method to determine if the character is alpha Use decision struction to determine if alpha to number is needed Display converted phone number
Many companies use telephone numbers like 555-GET-Food so the number is easier for their customers to remember. On a standard telephone, the alphabetic letters are mapped to numbers in the following fashion:
A, B, and C = 2
D, E, and F = 3
G, H, and I = 4
J, K, and L = 5
M, N, and O = 6
P, Q, R, and S = 7
T, U, and V = 8
W, X, y, and Z = 9
Write an application that asks the user to enter a 10-character telephone number in the format XXX-XXX-XXXX. The application should display the telephone number with any alphabetic characters that appeared in the original translated to their numeric equivalent. For example, if the user enters 555-GET-FOOD the application should display 555-438-3663. I need help with creating the following program using Python 3.2.
Also need to follow the following requirements:
Main() to control logic Use loop to examine each character User proper string method to determine if the character is alpha Use decision struction to determine if alpha to number is needed Display converted phone number
Many companies use telephone numbers like 555-GET-Food so the number is easier for their customers to remember. On a standard telephone, the alphabetic letters are mapped to numbers in the following fashion:
A, B, and C = 2
D, E, and F = 3
G, H, and I = 4
J, K, and L = 5
M, N, and O = 6
P, Q, R, and S = 7
T, U, and V = 8
W, X, y, and Z = 9
Write an application that asks the user to enter a 10-character telephone number in the format XXX-XXX-XXXX. The application should display the telephone number with any alphabetic characters that appeared in the original translated to their numeric equivalent. For example, if the user enters 555-GET-FOOD the application should display 555-438-3663.
Explanation / Answer
def main():
num=input("Enter a 10-character telephone number in the format XXX-XXX-XXXX:")
num=num.upper()
newNum=""
for i in num:
s=i
if str.isalpha(s):
if s=="A" or s=="B" or s=="C":
s=str(2)
elif s=="D" or s=="E" or s=="F":
s=str(3)
elif s=="G" or s=="H" or s=="I":
s=str(4)
elif s=="J" or s=="K" or s=="L":
s=str(5)
elif s=="M" or s=="N" or s=="O":
s=str(6)
elif s=="P" or s=="Q" or s=="R" or s=="S":
s=str(7)
elif s=="T" or s=="U" or s=="V":
s=str(8)
elif s=="W" or s=="X" or s=="Y" or s=="Z":
s=str(9)
newNum=newNum+s
print("The number entered is: "+newNum)
main()
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.