Menu

Following Question However Read Entire Question Planning Solution Create Input File Named Q43828823

You will do the following for this question. However, read theentire question before planning your solution.

  • Create an input file named q2.dat in the current directorywhere you stored this notebook with the following content.

[Jack Frost] [80, 50, 40, 20] [75, 75] [78.20, 77.20] [James Potter] [82, 56, 44, 30] [80, 80] [67.90, 78.72] [Dylan Rhodes] [77, 82, 23, 39] [78, 77] [80, 80] [Jessica Stone] [67, 55, 77, 21] [40, 50] [69, 44.56] [Tom Hanks] [29, 89, 60, 56] [65, 56] [50, 40.6]

  • There are four (4) separate fields in this file:

    1. name
    2. homeworks
    3. exams
    4. labs

    Except for the name field, the remaining ones are represented inthe same format as Python lists. However, note that this data ispurely text!

  • Read, preprocess, and store this data in memory using a list ofdictionaries like this:

    [ { “name”:”Jack Frost”, “homeworks” : [80, 50, 40, 20], “exams” : [75, 75], “labs” : [78.20, 77.20] }, { … } . . . ]

    Note that the name field must be a string, and the remainingfields must be lists of floating-point numbers.

  • Write a Python function named display_grades( student_data ),which, given this list of dictionaries with student grade data init, displays the data for all students in tabular format likethis:

    Student Name HW1 HW1 HW3 HW4 EX1 EX2 LAB1 LAB2 —————————————————————— Jack Frost 80 50 40 20 75 75 78.20 77.20 James Potter 82 56 44 30 80 80 67.90 78.72 Dylan Rhodes 77 82 23 39 78 77 80 80 Jessica Stone 67 55 77 21 40 50 69 44.56 Tom Hanks 29 89 60 56 65 56 50 40.6

  • Write a Python function named compute_average( student_data,grade_type=’homeworks’ ), which computes the average for a giventype of grade, the default being the homework grade. The grade_typeparameter should accept homeworks, exams, or labs
  • Write a Python function named sort_data( student_data,field_type=’name’, reverse=False ) that prints out the givenstudent data in ascending order (unless reverse is True)according to the specified field type. For example, if the fieldtype is name, then the student data should be printed out accordingto student name, in ascending order. The field_type shouldaccept name, hw1, hw2, hw3, hw4, ex1, ex2, lab1, or lab2, matchingeach column in the data set.

Expert Answer


Answer to You will do the following for this question. However, read the entire question before planning your solution. Create an …

OR