Question: 3. (a) Write a Python program, in a file called student_info.py, to create a data file called student_data.dat containing information for 1000 students. including last


3. (a) Write a Python program, in a file called student_info.py, to create a data file called student_data.dat containing information for 1000 students. including last name, first name, year in program, and GPA. For example, the file may look like: LastName0 FirstName0 4 3.25 LastName1 FirstName1 1 3.0 You should use the random module to generate values for the year and the GPA for each student. Note that the GPA values should be floating point values in the range [0,4], while the program year values can be assumed to be integer values in the range 1,5 (b) In a file called student.py, create a Student type that includes private attributes for last name, first name, year in program, and GPA. The initial- izer method should take no arguments. Include a method called update to accept a single string argument in the form LastName FirstName Year GPA (ie. space separated), and set all attributes to the respective values in the string. Include accessor methods to be used in the question below. (c) Write a Python program, in a file called majors.py, to read data from the student_data.dat file created above and create a list of Students using your Student type above. Assume that you do not know how many lines are in the file. Compute and output to a file the total number of students in each year of the program, and the average and median GPA for each year, as well as the overall total number of students and average GPA. The names of the input and output files should be obtained from the user. Sample output file Year Num Avg GPA Median_GPA 1 208 1.92 1.90 2 210 2.072.01 3 210 2.02 2.01 4 184 1.99 1.93 5 188 2.02 1.98 Total 1000 2.01
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
