Create a python program that would perform the given description below Program Description: T9 is a predictive text technology for mobile phones (specifically those that contain a 3×4 numeric keypad). It allows the user to press a numerical key and form a set of keys. With this set of keys, T9 figures out exactly the word the user meant to type based on the list of valid words also called a dictionary. Here is exactly how T9 works: If the user wants to type a message to someone using a cellphone pad, they will only use the digits 2 through 9. The table below provides the corresponding letters for each digit: If you wanted to type the message hello, you would just type 43556. Clearly, there are many alphabetic strings that correspond to this five-digit string, but of all of those, hello is the only word. It turns out that for most words, no other word will correspond to the same exact set of digits. This is how T9 works - it cross-references the digits pressed with a dictionary of words. Obviously, there are some instances where multiple words map to the same digits, such as "book" and "cool" which are both represented by "2665". In these cases, T9 selects the most frequently chosen word. Phones with advanced T9 adapt to the user's typical word choices. (This feature of T9 will not be covered in this activity). Write a program that translates messages typed in T9 to their alphabetic format. In the case that more than one message is possible, your program should simply calculate the total number of possible messages. (Note: This value should only be determined based upon the total number of possible combinations of words that could be formed and should not be restricted by the meaning of those words in any manner.) If no message is possible for the input T9 text, then your program should determine this as well. INPUT: The first line of the input file will contain a single integer n (1 ~ n ~ 20), indicating the number of words in the dictionary. Each of the next n input lines will contain a single word from the dictionary. Each word will only consist of lowercase letters (length ~ 1) and there will be no duplicate words in the dictionary. The next input line will contain a single integer, m, representing the number of messages to convert. Each of the next m lines will contain one message. A message will contain numeric strings (i.e., only digits 2 through 9) separated by spaces on a single line, with the first string starting in column 1 and each string is separated by a single space. OUTPUT: For each input message, print a heading. Then, output one of the following three options: If there is NO corresponding message, then print the following message out: not a valid text If there is exactly one possible message, then print out the corresponding message, all in lower case. If there is more than one possible message, then print a message of the following format: there are X possible messages; where X is the number of possible messages
Create a python
Program Description:
T9 is a predictive text technology for mobile phones (specifically those that contain a 3×4 numeric keypad). It allows the user to press a numerical key and form a set of keys. With this set of keys, T9 figures out exactly the word the user meant to type based on the list of valid words also called a dictionary. Here is exactly how T9 works: If the user wants to type a message to someone using a cellphone pad, they will only use the digits 2 through 9. The table below provides the corresponding letters for each digit:
If you wanted to type the message hello, you would just type 43556. Clearly, there are many alphabetic strings that correspond to this five-digit string, but of all of those, hello is the only word. It turns out that for most words, no other word will correspond to the same exact set of digits. This is how T9 works - it cross-references the digits pressed with a dictionary of words. Obviously, there are some instances where multiple words map to the same digits, such as "book" and "cool" which are both represented by "2665". In these cases, T9 selects the most frequently chosen word. Phones with advanced T9 adapt to the user's typical word choices. (This feature of T9 will not be covered in this activity).
Write a program that translates messages typed in T9 to their alphabetic format. In the case that more than one message is possible, your program should simply calculate the total number of possible messages. (Note: This value should only be determined based upon the total number of possible combinations of words
that could be formed and should not be restricted by the meaning of those words in any manner.) If no message is possible for the input T9 text, then your program should determine this as well.
INPUT: The first line of the input file will contain a single integer n (1 ~ n ~ 20), indicating the number of words in the dictionary. Each of the next n input lines will contain a single word from the dictionary. Each word will only consist of lowercase letters (length ~ 1) and there will be no duplicate words in the dictionary.
The next input line will contain a single integer, m, representing the number of messages to convert. Each of the next m lines will contain one message. A message will contain numeric strings (i.e., only digits 2 through 9) separated by spaces on a single line, with the first string starting in column 1 and each string is separated by a single space.
OUTPUT: For each input message, print a heading. Then, output one of the following three options:
If there is NO corresponding message, then print the following message out: not a valid text
If there is exactly one possible message, then print out the corresponding message, all in lower case.
If there is more than one possible message, then print a message of the following format: there are X possible messages; where X is the number of possible messages
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images