question archive Many companies use telephone numbers like 555-GET-FOOD so the number is easier for their customers to remember

Many companies use telephone numbers like 555-GET-FOOD so the number is easier for their customers to remember

Subject:Computer SciencePrice:2.86 Bought15

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, C: 2

D, E, F: 3

G, H, I: 4

J, K, L: 5

M, N, O: 6

P, Q, R, S: 7

T, U, V: 8

W, X, Y, Z: 9

using python 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.

 

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

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:

Step-by-step explanation

Here Is Answer :

 

Code :

 

def getNumber(alphabet):
    if alphabet in "ABC":
        return "2"
    elif alphabet in "DEF":
        return "3"
    elif alphabet in "GHI":
        return "4"
    elif alphabet in "JKL":
        return "5"
    elif alphabet in "MNO":
        return "6"
    elif alphabet in "PQRS":
        return "7"
    elif alphabet in "TUV":
        return "8"
    elif alphabet in "WXYZ":
        return "9"
    else:
        return alphabet


def phone_number(num):
    result = ''
    for ch in num:
        result += getNumber(ch)
    return result


number = input("Enter a phone number to be translated:")
print(phone_number(number))

 

Related Questions