I am building a program that prompts the user to load a csv file. The csv file always contains the columns StudentID, Name, Assignment1,2,3... The number of assignments varies.
I am trying to display a list of names, with one grade for each assignment and the final grade which I calculate from my imported function computeFinalGrade.
How can I change the last line my code to print the grades and the final grades for the right number of assignments?
Desired output: if the csv only has "Assignment1", the output should be:
"Michael Andersen has obtained the grades 10. The final grade is 10"
if the csv contains 5 assignments, the output should be:
"Michael Andersen has obtained the grades 10,7,12,7,10. The final grade is 10"
My code:
grades = np.genfromtxt(filename, delimiter=";", skip_header=1)
e = grades[:,2:]
f = computeFinalGrades(e)
df = pd.read_csv(filename,sep=';')
df['FinalGrade'] = f
for index, row in df.iterrows():
print('{} has obtained the grades {}, {}, {}. The final grade is {}'.format(row['Name'],row['Assignment1'],row['Assignment2'],row['Assignment3'],row['FinalGrade']))