Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions