Question: Create a function called ReadFile() with the following requirements: a. Single parameter with the name of the text file to open and read. b. Each
Create a function called ReadFile() with the following requirements: a. Single parameter with the name of the text file to open and read. b. Each line of the text file must be added to a dictionary. In each element of the dictionary, the key is the line number and the value is the line of text read from the file. c. The return value of the function is the dictionary that was created while reading the file. d. Save this function in a file called ReadFile.py e. Create a program to test this function, making sure you import the function module. Name the program TestReadFile.py (8 marks) (Continued on next page) 3. Create a function called GetValue() with the following requirements: a. Two parameters i. the first parameter is the name of a dictionary with the same structure as the one created in question 2 above (i.e. the key is an integer and the value is a string) ii. the second parameter is the key of the value you want to retrieve b. The return value is the value retrieved from the dictionary. If the operation failed, then return the string "!!!None!!!". c. Save this function in a file called GetValue.py d. Create a program to test this function, making sure you import the function module. Name the program TestGetValue.py You may use the output of question 2 as input in this question.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
