def write_grades_file(filename, grades): Given a filename and a dictionary in the grades format, write the values in the
Posted: Wed Apr 27, 2022 3:46 pm
Need Coding in Python. Can you please explain the logic using
comments?
def write_grades_file(filename, grades): Given a filename and a dictionary in the grades format, write the values in the given dictionary into the given file. The text file format should be the same as what was used in the read_grades_file function. Note 1: A good way to check your work on these two functions is to try and read a file you've written, and vice versa. Note 2: Make sure not to overwrite any important files like the tester, or the test case files! Examples: Here's a dictionary in the grades format for a student named Alan Turing: {'name': 'Alan Turing', 'pa': [1.0, 0.0, 1.0, 0.0, 1.0), 'lab': [1.0, 1.0, 1.0, 0.0, 1.0), 'zy': (0.0, 0.0, 1.0, 0.0, 1.0), 'midi': 1.0, 'mid2': 0.0, 'final': 1.0) And here is how the output file should look given this input: name, Alan Turing pa, 1.0, 0.0, 1.0, 0.0, 1.0 lab, 1.0, 1.0, 1.0, 0.0, 1.0 zy, 0.0, 0.0, 1.0, 0.0, 1.0 midi, 1.0 mid2, 0.0 final, 1.0
comments?
def write_grades_file(filename, grades): Given a filename and a dictionary in the grades format, write the values in the given dictionary into the given file. The text file format should be the same as what was used in the read_grades_file function. Note 1: A good way to check your work on these two functions is to try and read a file you've written, and vice versa. Note 2: Make sure not to overwrite any important files like the tester, or the test case files! Examples: Here's a dictionary in the grades format for a student named Alan Turing: {'name': 'Alan Turing', 'pa': [1.0, 0.0, 1.0, 0.0, 1.0), 'lab': [1.0, 1.0, 1.0, 0.0, 1.0), 'zy': (0.0, 0.0, 1.0, 0.0, 1.0), 'midi': 1.0, 'mid2': 0.0, 'final': 1.0) And here is how the output file should look given this input: name, Alan Turing pa, 1.0, 0.0, 1.0, 0.0, 1.0 lab, 1.0, 1.0, 1.0, 0.0, 1.0 zy, 0.0, 0.0, 1.0, 0.0, 1.0 midi, 1.0 mid2, 0.0 final, 1.0