Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python 3 Phone Numbers to Letters Write a program that will print to the screen

ID: 3825865 • Letter: P

Question

Python 3 Phone Numbers to Letters

Write a program that will print to the screen all of the words and the associated numbers that could be generated through an 800 phone number that has the prefix 555. The numbers 1 and 0 on a keypad do not have letters associated with them.

Here are some examples of the words that would be generated and the format for the output:

Number Word 1.800.555.2222 1.800.555.AAAA 1.800.555.2222 1.800.555.AAAB 1.800.555.2222 1.800.555.AAAC 1.800.555.2223 1.800.555.AAAD 1.800.555.2223 1.800.555.AAAE 1.800.555.2223 1.800.555.AAAF 1.800.555.2224 1.800.555.AAAG 1.800.555.2224 1.800.555.AAAH 1.800.555.2224 1.800.555.AAAI

Explanation / Answer

alph_num_dict = {'a': '2', 'b': '2', 'c': '2',

             'd': '3', 'e': '3', 'f': '3',

             'g': '4', 'h': '4', 'i': '4',

             'j': '5', 'k': '5', 'l': '5',

             'm': '6', 'n': '6', 'o': '6',

             'p': '7', 'q': '7', 'r': '7', 's': '7',

             't': '8', 'u': '8', 'v': '8',

             'w': '9', 'x': '9', 'y': '9', 'z': '9'}

for letter, digit in alph_num_dict.items():

print ("1.800.555." + str(digit) + str(digit) + str(digit) + str(digit), end=" ")

print ("    1.800.555." + str(letter) + str(letter) + str(letter) + str(letter))