subject

Please create a python module named homework. py and implement the functions outlined below. Below you will find an explanation for each function you need to implement. When you are done please upload the file homework. py to Grader Than. Please get started as soon as possible on this assignment. This assignment has many problems, it may take you longer than normal to complete this assignment. This assignment is supposed to test you on your understanding of reading and writing to a text file and working with JSON objects.
1. def read(file_path: str)->str:
"""
Reads the entire file at the specified file path. The function returns all the text in the file as a string, if
the file is empty it will return an empty string ("").
:param file_path: A path to a file
:return: All the text in the file
"""
2. def write(file_path:str, text:str=''):
"""
Clears the file at the specified file path then writes the specified line to the file. If the function is invoked
without a line parameter or the line variable is None nothing is written to the file but the file should still be
cleared. If the file does not exist a new file is created, regardless if a text is specified.
:param file_path: A path to a file
:param line: None
:return:
"""
3. def write_last_line(file_path:str, text:str=''):
"""
Writes the specified line to the file as the last line. If the text parameter does not start with a new line
character this adds a new line character to the text parameter so that the text is written on the next line of
the file. If the function is invoked without a line parameter or the line variable is None nothing is written to
the file. If the file does not exist a new file is created, regardless if a text is specified.
:param file_path: A path to a file
:param text: The last line to be written to the file.
:return: None
"""

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:30, robert7248
You have a large, late-model pick-up truck with a rear seat. the pick-up truck weighs 6,500 pounds. the florida seat belt law
Answers: 1
image
Computers and Technology, 23.06.2019 06:00, 573589
What machine listens for http requests to come in to a website’s domain? a. a router b. a browser c. a server d. a uniform resource locator
Answers: 1
image
Computers and Technology, 24.06.2019 02:00, sameh0425
Which steps will open the system so that you can enter a question and do a search for
Answers: 1
image
Computers and Technology, 24.06.2019 03:00, paguy12
What is one potential problem associated with an organization purchasing new technology early in its lifecycle
Answers: 1
You know the right answer?
Please create a python module named homework. py and implement the functions outlined below. Below y...

Questions in other subjects:

Konu
Physics, 11.03.2021 20:50