Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Above is Criteria and the bold is the function I should make exactly same as my code. (Use Python) Could you modify my code for

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Above is Criteria and the bold is the function I should make exactly same as my code.

image text in transcribed

(Use Python)

Could you modify my code for as in

"Expected output"?

43556 : gekko

hello

Also some fixing function below.

image text in transcribed

image text in transcribedimage text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Task description A few weeks ago, you managed to get yourself a job at a local warehouse where you collect goods for the regular customers. Each evening you collect what the customers have ordered for the next day. It is an easy job that pays well and you are really happy about it, but there is one problem. All orders have a unique identifier called order number that consists of five digits, and you can not help yourself from trying to translate the order number into a real word each time you pick up a new order. For example, if you get the order number 78676 you might translate it into the word storm (explanation below). You always try to find a translation before you finish collecting the goods for an order but sometimes it is too tricky, and for this reason you would like to create a script that can solve the translation for you. By sheer luck it turns out that the system at work can email you a file with all the order numbers you have picked in a day. You want your script to take two filenames (full path) as command line arguments. The first argument shall be the file with the order numbers and the find all the words that can be constructed using those digits. The words must be proper words listed in the file linked by the second command line argument. The file with words in it shall be a regular text file with one word per line and the file with all the order numbers shall be a file that contains a pickled Python Set that stores all the order numbers as strings All the possible words for each order number shall be displayed on the screen using this exact format: The translation from digits to letters shall be done using the ITU E.161 /ISO 99958G standard. This is the same standard used when you use the keypad on a phone to translate from digits to letters. The following picture shows the translation scheme: The script must implement the following functions and constants: TRANSLATION This is a global constant that contains a dictionary. The dictionary shall store the digits 0 - 9 as keys (stored as strings) and their corresponding value shall be the letters represented by each digit according to the ITU E.161/ISO 9995-8 standard. The letters shall be stored in one string without any spaces in between the individual letters. For example, {2 ': 'abc' }. read_orders(filename) Opens the file linked by the string filename. Using pickle the function reads, and returns, the Set of order numbers stored in the file. If the filename is invalid the function shall raise a FileNotFoundError. read_words(filename) Creates a list that is populated with all the words read from the file linked by the string filename. The file stores one word on each line. The list of the words shall be returned from the function. If the filename is invalid the function shall raise a FileNotFoundError. find_all_possible_combinations(order_number) The overarching goal of this function is to return all the possible combinations that can be achieved using the digits in the order_ output shall be a list of strings. An example of how this function works can be seen below: input: '23' output: ['ad', 'ae', 'af', 'bd', 'be', 'bf', 'cd', 'ce', 'cf'] find_all_possible_combinations(order_number) The overarching goal of this function is to return all the possible combinations that can be achieved using the digits in the order_number string. The output shall be a list of strings. An example of how this function works can be seen below: input: '23' output: ['ad', 'ae', 'af', 'bd', 'be', 'bf', 'cd', 'ce', 'cf'] Another way of looking at how this function works is to have a look at the following image: add_digit(digit, combinations) This function shall be used by find_all_possible_combinations. The two parameters are the next digit to add and the current collection of combinations found. The functionality is best described with an example where we try to find all combinations for ' 23 ': First call to function: Input: '2' and [] Output: ['a', 'b', 'c'] Explanation: ' 2 ' is the first digit in the number we want to translate and the empty list is because we do not have any previous combinations yet. The output is all the different letters we can get by translating ' 2 ' into letters. Second call to function: Input: '3' and ['a', 'b', 'c'] Output: ['ad', 'ae', 'af', 'bd', 'be', 'bf', 'cd', 'ce', 'cf'] Explanation: ' 3 ' is the second digit in the number we want to translate and the ['a', 'b', 'c'] is from the output in the first step, or in other words, filter_valid_words(possible_combinations, valid_words) The parameter possible_combinations is a list of strings that contain all the possible combinations of letters you can get from an order number and the valid_words parameter is also a list of strings but it contains all the valid, real, words read from the word list file sent as a command line argument to the script. The function shall return a list with all combinations from possible_combinations that also exists in valid_words. display_possible_words(order_number, words) This function is responsible for displaying one order_number and the potential real words it can translate into. The information shall be displayed on the format described earlier in the task. main() Uses the command line arguments to read the files with the order numbers and words, and then loops through all the order numbers, finds all the in the script displaying the following message to the user if any of the files given as command line arguments are not valid: Error: There was a problem with at least one of the files. To avoid problems with the testing framework, and to build a good habit, call the main function using the following construct: No Summary Score Pass 1 Validate functionality 0/1 1.1 Running the script from the command line with valid arguments shall result in the script producing a well formatted, correct, output Output Difference Input Errors Exit code 1 Expected output i Actual output 1. 43556: gekko No output. 2. hello 2 Testing invalid command line arguments 2.1 Starting the script using the command line, with an invalid path argument, shall result in the error message being printed 5 Testing the add_digit function 0/1 Results Output pytest (0 / 3) pytest (0 / 3) But got: ' But got: if mame \( _{\text {main() }}^{\text {nain__": }}= \) " main_

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

List the different categories of international employees. page 642

Answered: 1 week ago

Question

Explain the legal environments impact on labor relations. page 590

Answered: 1 week ago