Question

In: Computer Science

In PYTHON On a standard telephone, alphabetic letters are mapped to numbers in the following fashion:...

In PYTHON

On a standard telephone, 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, and R = 7

T, U, and V = 8

W, X, Y, and Z = 9

Write a fruitful function that takes any string of alphanumeric characters and returns a string with all alphabetic characters in the argument translated into their numeric equivalent, using the above mapping.

Alphabetic Telephone Number Translator: Many companies use telephone numbers like 713-GET-FOOD to make it easier for their customers to remember. But for customers, it is easier to dial a pure numeric phone number, rather than an alphanumeric number. Write an application program that asks the user to enter a 10 character alphanumeric telephone number in the form of XXX-XXX-XXXX. The application should then call your function to translate the alphanumeric phone number into its equivalent numeric phone number and display the result. For example if the user enters 713-GET-FOOD the application should display 713-438-3663. The application should allow the user to continue translating phone numbers until she/he decides to stop. Use meaningful variable names.

Solutions

Expert Solution

Python Program:

def telephone_number_translator():

    userInput = True

    while userInput:
        # phoneNumber => For company use
        phoneNumber = input('Enter the number in the format of XXX-XXX-XXXX eg. {713-GET-FOOD}: ')
        newPhoneNumber = '' # For customer use
        for char in phoneNumber: # for each character in input phone number
            # Mapping the character by using if-else except "-"
            if char == 'A' or char == 'B' or char == 'C':
                char = '2'
            elif char == 'D' or char == 'E' or char == 'F':
                char = '3'
            elif char == 'G' or char == 'H' or char == 'I':
                char = '4'
            elif char == 'J' or char == 'K' or char == 'L':
                char = '5'
            elif char == 'M' or char == 'N' or char == 'O':
                char = '6'
            elif char == 'P' or char == 'Q' or char == 'R' or char == 'S':
                char = '7'
            elif char == 'T' or char == 'U' or char == 'V':
                char = '8'
            elif char == 'W' or char == 'X' or char == 'Y' or char == 'Z':
                char = '9'
            newPhoneNumber = newPhoneNumber + char # for "-"

        print("Customer New Telephone Number : ", newPhoneNumber)

        choice = input("\nDo you want to convert another Telephone Number (Yes/No) ? : ")
        if (choice.lower() == "yes"):
            userInput = True
        elif (choice.lower() == "no"):
            print("Thank you !!")
            break
        
        
if __name__ == '__main__':
    print("********************Welcome To Alphabetic Telephone Number Convertor***********************\n")
    telephone_number_translator()

Output:

Thumbs Up Please !!!


Related Solutions

Alphabetic Telephone Number Translator           Many companies use telephone numbers like 555-GET-FOOD so the number is...
Alphabetic Telephone Number Translator           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            ...
To make telephone numbers easier to remember, some companies use letters to show their telephone number....
To make telephone numbers easier to remember, some companies use letters to show their telephone number. For example, using letters, the telephone number 438-5626 can be shown as GET LOAN. In some cases, to make a telephone number meaningful, companies might use more than seven letters. For example, 225-5466 can be displayed as CALL HOME, which uses eight letters. Instructions Write a program that prompts the user to enter a telephone number expressed in letters and outputs the corresponding telephone...
Write pseudocode for a function that translates a telephone number with letters in it (such as...
Write pseudocode for a function that translates a telephone number with letters in it (such as 1-800-FLOWERS) into the actual phone number. Use the standard letters on a phone pad
The code numbers are listed in the Alphabetic Index. why not code directly from it?
The code numbers are listed in the Alphabetic Index. why not code directly from it?
(Tokenizing Telephone Numbers) Write a program that inputs a telephone number as a string in the...
(Tokenizing Telephone Numbers) Write a program that inputs a telephone number as a string in the form (555) 555-5555. The program should use function strtok to extract the area code as a token, the first three digits of the telephone number as a token and the last four digits of the phone number as a token. The seven digits of the phone number should be concatenated into one string. The program should convert the area-code string to int and convert...
In Java lang Standard telephone keypads contain the digits zero through nine. The numbers two through...
In Java lang Standard telephone keypads contain the digits zero through nine. The numbers two through nine each have 3~4 letters (case insensitive) associated with them. Many people find it difficult to memorize phone numbers, so they use the correspondence between digits and letters to develop seven-letter words that correspond to their phone numbers. For example, a person whose telephone number is 686-2377 might remember it as "NUMBERS." Digit Letters 2 ABC 3 DEF 4 GHI 5 JKL 6 MNO...
IN JAVA pls Standard telephone keypads contain the digits zero through nine. The numbers two through...
IN JAVA pls Standard telephone keypads contain the digits zero through nine. The numbers two through nine each have 3~4 letters (case insensitive) associated with them. Many people find it difficult to memorize phone numbers, so they use the correspondence between digits and letters to develop seven-letter words that correspond to their phone numbers. For example, a person whose telephone number is 686-2377 might remember it as "NUMBERS." Digit Letters 2 A B C 3 D E F 4 G...
Tokenizing Telephone Numbers Write java application that inputs a telephone number as a string in the...
Tokenizing Telephone Numbers Write java application that inputs a telephone number as a string in the form (555) 555-5555. The application should use String method split to extract the area code as a token, the first three digits of the phone number as a token and the last four digits of the phone number as a token. The seven digits of the phone number should be concatenated into one string. Both the area code and the phone number should be...
Modify Java program to accept a telephone number with any numberof the letters, using the...
Modify Java program to accept a telephone number with any number of the letters, using the if else loop. The output should display a hyphen after the first 3 digits and subsequently a hyphen (-) after every four digits. Also, modify the program to process as many telephone numbers as the user wants.
*PERMUTATIONS* How many tablets of 3 letters and 3 numbers can we form with the letters...
*PERMUTATIONS* How many tablets of 3 letters and 3 numbers can we form with the letters {A, B, C, D, E} and the 10 digits if the tablet should have: ◦ Letters and numbers should be kept together without repetition? ◦ Letters and numbers should be kept together with repetition? ◦ Letters and numbers do not have to be kept together without repetition? ◦ Letters and numbers do not have to be kept together with repetition?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT