Functions The signature of each function is provided below, do not make any changes to them otherwise the tester will no

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Functions The signature of each function is provided below, do not make any changes to them otherwise the tester will no

Post by answerhappygod »

Functions The Signature Of Each Function Is Provided Below Do Not Make Any Changes To Them Otherwise The Tester Will No 1
Functions The Signature Of Each Function Is Provided Below Do Not Make Any Changes To Them Otherwise The Tester Will No 1 (156.26 KiB) Viewed 40 times
Need Coding in Python. Can you please explain the logic behind
the code and how you approached it?
Functions The signature of each function is provided below, do not make any changes to them otherwise the tester will not work properly. The following are the functions you must implement: def read_grades_file(filename, project=False): Given a filename, open and read the given file and parse it into a dictionary in the grades format. The text file format should have one line for each value. The order is: • Name • Programming Assignments • Labs • zyBooks • Midterm . Midterm2 . Final Each line will contain a list of values separated by spaces. The first value on each line will be a string indicating the assignment type of the values that follow. The value for the name will be a string, and leading and trailing spaces should be ignored (you may find the string method strip () to be useful for this). The value for the "mid1", "mid", and "final" assignment types will always be a single floating point value. All the other assignment types will have one or more floating point values. If the parameter project is False (default), then these grade values should be stored in the returned dictionary as-is. On the other hand, if project is true then you should check for missing grade values. If project is true and there are fewer than 9 programming assignments, 11 labs, or 15 zyBooks, you will need to project values for all of the missing grades (you do not need to consider the case where there are more grades). To do this for a given assignment type, compute the average grade for that assignment type, and then add copies of that average to the end of the given grade values so that that assignment type has the correct number of grades. For example, if the file had the following line "pa, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0", then there are only 7 programming assignment grade values. If project were True, you would compute the average of the given grades (1.0+2.0+3.0+4.0+5.0+6.0+7.0)/7 = 4.0), and add that to the end of the list of grade values, so that the dictionary's value for the key "pa" would be the list [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 4.0, 4.0). = Examples: The "mason.grades" file included with the tester should look like this: name, George Mason pa, 100.0, 100.0, 95.0, 95.0, 97.0 lab, 100.0, 100.0, 100.0, 0.0, 100.0 zy, 100.0, 100.0, 100.0, 100.0, 100.0 midi, 90.0 mid2, 80.0 final, 85.0 When this file is parsed with project=False, the returned dictionary should look like this {'name': 'George Mason', 'pa': [100.0, 100.0, 95.0, 95.0, 97.0), 'lab': [100.0, 100.0, 100.0, 0.0, 100.0], 'zy': [100.0, 100.0, 100.0, 100.0, 100.0], 'midl': 90.0, 'mid2': 80.0, 'final': 85.0) The same file when parsed with project=True, the returned dictionary should look like this {'name': 'George Mason', 'pa': [100.0, 100.0, 95.0, 95.0, 97.0, 97.4, 97.4, 97.4, 97.4), 'lab': [100.0, 100.0, 100.0, 0.0, 100.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0), 'zy': [100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0], 'midi': 90.0, 'mid2': 80.0, 'final': 85.0)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply