Question: Hi, I am working on a project for python and I would like some help with these two functions, thanks. a) def open_file(): Prompts the

Hi, I am working on a project for python and I would like some help with these two functions, thanks.Hi, I am working on a project for python and I would

a) def open_file(): Prompts the user to enter a year number for the data file. The program will check whether the year is between 1990 and 2019 (both inclusive). If year number is valid, the program will try to open data file with file name 'yearXXXX.txt', where XXXX is the year. Appropriate error message should be shown if the data file cannot be opened or if the year number is invalid. The year is invalid if it is not a number between 1990 and 2019, inclusively. The invalid year error is shown in this case. If the loop is correct but the file does not exist, the other error will be output. This function will loop until it receives proper input and successfully opens the file. It returns a file pointer and year. Hint: use string concatenation to construct the file name. i. Parameters: None ii. Display: prompt and error message iii. Return: file pointer and int b) def handle_commas (s,T) int or float or None The parameters are s, a string, and T, a string. The expected values of T are int and float; any other value returns None. If the value of T is int, the string s will be converted to an int and that int value will be returned. Similar for float. If a value of s cannot be converted to an int or float, None will be returned (hint: use try- except). Note: this is the same function we had in Project 5. i. Parameters: str, str ii. Display: nothing iii. Returns: int or float or None

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!