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 Complete the function translate() that will accept a 10-character telephone number in the format XXX-XXX-XXXX as a string parameter. The function should return 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 program should display 555-438- 3663. def translate (phoneNumber: str): pass def testTranslate(): print (translate ("555-GET-FOOD"), end = "") print ("Correct") if translate ("555-GET-FOOD")=="555-438-3663" else print ("Incorrect") print (translate ("312-uso-Smrt"), end = "") print ("Correct") if translate ("312-uSo-Smrt") == "312-876-7678" else print ("Incorrect") if name _main__': testTranslate()

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 20PE
icon
Related questions
Question

Help! how do I fix my python coding question for this? (my code also provided)

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
Complete the function translate() that will accept a 10-character telephone number in the
format XXX-XXX-XXXX as a string parameter. The function should return 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 program should display 555-438-
3663.
Transcribed Image Text: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 Complete the function translate() that will accept a 10-character telephone number in the format XXX-XXX-XXXX as a string parameter. The function should return 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 program should display 555-438- 3663.
def translate (phoneNumber: str):
pass
def testTranslate():
print (translate ("555-GET-FOOD"), end = "")
print ("Correct") if translate ("555-GET-FOOD")=="555-438-3663" else print ("Incorrect")
print (translate ("312-uso-Smrt"), end = "")
print ("Correct") if translate ("312-uSo-Smrt") == "312-876-7678" else print ("Incorrect")
if name
_main__':
testTranslate()
Transcribed Image Text:def translate (phoneNumber: str): pass def testTranslate(): print (translate ("555-GET-FOOD"), end = "") print ("Correct") if translate ("555-GET-FOOD")=="555-438-3663" else print ("Incorrect") print (translate ("312-uso-Smrt"), end = "") print ("Correct") if translate ("312-uSo-Smrt") == "312-876-7678" else print ("Incorrect") if name _main__': testTranslate()
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage