Question
this is what i have so far but i keep getting this error (float(row[i]) - float(row[i-6])) ValueError: could not convert string to float: 'Quiz5'
this is what i have so far but i keep getting this error " (float(row[i]) - float(row[i-6])) ValueError: could not convert string to float: 'Quiz5' "
import csv
fName = "/Users/class.csv"
try: file = open(fName, "r") reader = csv.reader(file) for row in reader: for i, v in enumerate(row): if i == 5: (float(row[i]) - float(row[i-6])) print(row)
except IOError: print("The file does not exists:",fName)
structure of csv file:
Name -- quiz 1 -- quiz2 -- quiz3 -- quiz4 -- quiz5 -- quiz6--- quiz7
ashely 12 12 30 50 54 45 30
mike 30 45 80 55 67 65 66
for about 20 columns
The class.csv file contains some in regard to students grades for a specific class. The columns contain the grade the students have received for each assignment. Write a program to read the file, then print the name of the student with the smallest difference in 'Quiz5' and 'Quiz6' grades. Use try/catch to print out "The file does not exists" in case the class.csv file does not exist You can use the csv module to read the csv file. Look at Python documentation for csv.reader() to learn how to use it. Try to right your program in the most compact way possible by using list comprehensions There are 10 bonus points if you use the built-in function min() in order to find the smallest differenceStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started