
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 nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

- In java, the Arrays class contains a static binarySearch() method that returns …… if element is found. false true (-k–1) where k is the position before which the element should be inserted The index of the elementarrow_forwardPlease answer the question in the screenshot. The language used here is Java.arrow_forwardImplement the following: Given: person = {'name': 'bob'}1) Add the key/value pair 'emplStatus': 'Retired' to the dictionary person.2) Access the values in the dictionary person to print the following. Example OutputBob's employment status is Retired. NEED HELP WITH PYTHONarrow_forward
- In Java using recursion, create a program with a GUI that will allow a user to enter five numbers. The program will provide the product of all five numbers using recursive methods.arrow_forwardFor any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed by a comma (no spaces). Ex: If the input is: 32 105 101 35 10 20 30 40 the output is: 20,30, 1 #include 2 3 int main(void) { const int SIZE_LIST = 4; int keysList[SIZE_LIST]; int itemsList[SIZE_LIST]; int i; 4 6 7 8 scanf("%d", &keysList[0]); scanf ("%d", &keysList[1]); scanf("%d", &keysList[2]); scanf("%d", &keysList[3]); 10 11 12 13 scanf ("%d", &itemsList[0]); scanf ("%d", &itemsList[1]); scanf("%d", &itemsList[2]); scanf ("%d", &itemsList[3]); 14 15 16 17 18 19 /* Your code goes here */ 20 21 printf("\n"); 22 23 return 0; 24 }arrow_forwardA tuple that contains elements is true. True or false? In Python.arrow_forward
- show: Lists the items that the wizard is currently carrying along with the index for each item and the weight of that item. See sample runs below. As shown in the sample this function also prints the total weight of the items along with the max weight limit of 100 lbs. Hint: You can use the sum function in Python to calculate the sum of weights. E.g. sum(weights) will return the sum of all the items in the weights list. grab_item: Add a new item while enforcing the following policy: There is a limit of 4 on the number of items the wizard can carry and limit of 100 lbs on the total weight the wizard can carry. So specifically, if the wizard is already carrying 4 items, print message that “You can't carry anymore items. Drop something first.” And return out of the function. Otherwise prompt the user for the name and the weight of the new item. Next check whether with the addition of the new item, the total weight will exceed the limit of 100 lbs. If so, print a message saying weight…arrow_forwarddef print_main_menu(menu): """ Given a dictionary with the menu, prints the keys and values as the formatted options. Adds additional prints for decoration and outputs a question "What would you like to do?" """ if __name__ == "__main__": the_menu = {} # TODO 1: add the options from the instructions opt = None while True: # print_main_menu(...) # TODO 1: uncomment, define the function, and call with the menu as an argument print("::: Enter an option") opt = input("> ") if opt == ...: # TODO 2: make Q or q quit the program print("Goodbye!\n") break # exit the main `while` loop else: if ...: # TODO 3: check of the character stored in opt is in the_menu dictionary print(f"You selected option {opt} to > {the_menu[opt]}.") else: print(f"WARNING: {opt} is an invalid option.\n")arrow_forwardIn Python NO IMPORT PICKLE Please check pictures and fix code. Write a program that keeps names and email addresses in a dictionary as key-value pairs. This is the Required Output example: Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program Enter your choice: 2 Enter name: John Enter email address: John@yahoo.com That name already exists Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program Enter your choice: 2 Enter name: Jack Enter email address: Jack@yahoo.com Name and address have been added Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5.…arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





