- 2nd Jul 2024
- 17:08 pm
In this assignment, we will read quiz grades from a CSV file, calculate student averages, and generate a comprehensive report. Our experts will guide you through each step, ensuring accurate data processing and clear, well-formatted output.
Assignment Specification:
Based on the grades.csv file Reading a csv file,, develop a solution to read in all quiz grades for each student record. Each line in the file contains the following fields: Student Last name, first name, ID #, quiz1 grade,....... quiz n grade. It is not known the exact number of quizzes taken; if five, the average is based on 5 grades...if 8 quizzes, then the average is based on 8 quizzes, and so on... If a student missed a quiz, a grade of zero ( 0 ) will be assigned (the input has an empty spot between commas in the file). Objective: Read in grades and calculate averages. The average is based on the student's performance in all quizzes. If the student has taken more than 6 quizzes the lowest grade is dropped, and not included in the average. In addition to providing the students' averages, you will list the average for each quiz. All student averages should be accurate to 2 decimal places, and quiz averages to 1 decimal place. Use the template below to produce a report. Do NOT reproduce the 'ruler' at the top. It's there as a guideline. You can use it to see whether your output lines up properly in your columnar fields. Grades might have a single decimal place (no deed to display decimal if not present). "Student Grade Report" (the title) should be centerred above the report, based on the report width. Students' names should be "Proper or Name case", with only the first initial as shown, and right justified. Students' averages should have 2 decimals. Quiz averages precise to a single decimal Grade columns should be 'decimal aligned'. While it's *possible* there might be 10 quizzes, you'll only print out the necessary columns (if only 7 quizzes, don't print 8, 9 and 10). Replace "N" in "N Students" with the number of student records to display. Student names should appear in alpha order (lastname, firstname) in the listing.
Calculating Student Quiz Averages from CSV Data - Get Assignment Solution
Please note that this is a sample assignment solved by our Python Programmers. These solutions are intended to be used for research and reference purposes only. If you can learn any concepts by going through the reports and code, then our Python Tutors would be very happy.
- Option 1 - To download the complete solution along with Code, Report and screenshots - Please visit our Python Assignment Sample Solution page
- Option 2 - Reach out to our Python Tutors to get online tutoring related to this assignment and get your doubts cleared
- Option 3 - You can check the partial solution for this assignment in this blog below
Free Assignment Solution - Calculating Student Quiz Averages from CSV Data
numberOfStudents = 0
numberOfGrades = 0
try:
file= open("grades.csv","r")
line = file.readline()
numberOfGrades = len(line.split(",")) - 1
numberOfStudents = len(file.readlines())
file.close()
file= open("grades.csv","r")
line = file.readline()
line = file.readline()
print("....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8")
print("....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0")
print(" Student Grade Report ")
print()
print('{:^20s} '.format(str(numberOfStudents)+" Students"),end="")
for i in range(1,numberOfGrades + 1):
print('{:^5s} '.format("Q"+str(i)),end="")
print('{:^4s} '.format("Avg."),end="")
print()
print("-"*20 + " ",end = "")
for i in range(numberOfGrades ):
print("-"*5+ " ",end="")
print("-"*6+ " ",end="")
print()
allQuiz = []
while(line):
sum = 0
temp = line.split(",")
quiz = temp.copy()
quiz.pop(0)
allQuiz.append(quiz)
print("%20s "%(temp[0]) , end= "")
for i in range(1,len(temp)):
print("%5.1f "%(float(temp[i])),end="")
sum += float(temp[i])
print("%6.2f "%(sum/(len(temp)-1)),end="")
print()
line = file.readline()
for i in range(len(allQuiz)):
for j in range(len(allQuiz[i])):
allQuiz[i][j] = float(allQuiz[i][j])
print("-"*20 + " ",end = "")
for i in range(numberOfGrades ):
print("-"*5+ " ",end="")
print("-"*6+ " ",end="")
print()
print("%20s "%("Average") , end= "")
res = list()
for j in range(0, len(allQuiz[0])):
tmp = 0
for i in range(0, len(allQuiz)):
tmp = tmp + allQuiz[i][j]
res.append(tmp)
for i in res:
print("%5.1f "%(i/numberOfStudents),end="")
file.close()
except Exception as ex:
print(ex)
Get the best Python assignment help and tutoring services from our experts now!
About The Author - John Doe
John Doe is an experienced Python programmer with a strong background in data processing and analysis. He specializes in developing efficient solutions for complex data manipulation tasks, including handling CSV files, calculating statistical averages, and generating detailed reports. John's expertise ensures accurate and reliable results, making him a valuable resource for tackling intricate programming challenges.