Question: The following is in Python. Any help would be highly appreciated! This is the existing code given: import os def read_file(): ''' Prompt user for
The following is in Python. Any help would be highly appreciated!


This is the existing code given:
import os
def read_file(): ''' Prompt user for a file containing a 5 day forecast and then print it out. ''' def write_file(): ''' Prompt the user for a file to write to. Prompt for a 5 day forecast and write the contents to the file. ''' def print_menu(): print() print("1. Read File") print("2. Write File") print("3. Exit")
i = -1 while i not in [1, 2, 3]: i = int(input("Choose: ")) return i
def main(): print("Welcome to the Weather Monitor!")
i = print_menu() while i != 3: if i == 1: read_file() elif i == 2: write_file() i = print_menu()
if __name__ == '__main__': main()
File I/O Lab Overview In this lab, you will learn modify an existing program to read and write files. Contents Overview Contents Files Instructions Files . file lab.py Instructions You have been tasked with finishing a program to read and write 5-day forecast data. Right now the program consists of a menu with stub functions for each option. When a user selects Read File' the program should prompt the user for a filename and then print the contents of the file. If a user selects 'Write File' the program should prompt the user for a filename, prompt the user for 5 days worth high temperatures, and then write that data to the text file Data should be written to the text file in the following format: Day 1: 87 Day 2: 75 Day 3: 78 Day 4: 80 Day 5: 81 Design your program to match the sample execution below
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
