Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Could you modify my coding in python as on each expected output? This is the concept V 1.1 Running the script from the command line

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

image text in transcribedimage text in transcribed

Could you modify my coding in python as on each "expected output"?

This is the concept

image text in transcribed

image text in transcribed

image text in transcribed

V 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 Expected output i Actual output 2 Testing invalid command line arguments V2.1 Starting the script using the command line, with an invalid path argument, shall result in the error message being printed Output Difference Input Errors Exit code Expected output i Actual output 1. Error: - There was a problem with at least one of the files. No output. test_add_digit Calling the function with '3' and '['a', 'b', 'c']' should result in the function returning '['ad', 'ae', 'af', 'bd', 'be', 'bf', 'cd', 'ce', 'cf']' AssertionError: Expecting the result: 7 Testing the display_possible_words function 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 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 B/ISO99958 E 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 09 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 all 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_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 ': 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, our previously found combinations. The output is all the different combinations of letters we can get by first translating a ' 2 ' and then a 3 . 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 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 are 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) 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 valid words, and prints them. The main function shall use the other functions to accomplish its tasks and it shall be responsible for the erromere 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

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

Sybase Database Administrators Handbook

Authors: Brian Hitchcock

1st Edition

0133574776, 978-0133574777

More Books

Students also viewed these Databases questions

Question

Briefly state the purposes of a statement of cash flows.

Answered: 1 week ago

Question

8. Do the organizations fringe benefits reflect diversity?

Answered: 1 week ago

Question

7. Do the organizations social activities reflect diversity?

Answered: 1 week ago