Question: Write a Python program that creates a file named grades 2 . csv . The new file should contain all of the information from grades.csv

Write a Python program that creates a file named grades2.csv. The new file should contain all of the information from grades.csv In addition, there should be a fourth column entitled Average. For each student, the value in the new column should be the average of the two grades.
excel output:
Cooper, 85,95
Eli, 85,80
Leah, 100,96
Gabe, 71,100
Amber, 75,89
python code:
infile = open("grades.csv","r")
outfile = open("grades2.csv","w")
aline = infile.readline()
outfile.write("\t"+"Average
")
while aline:
items = aline.split()
dataline = items[0]+"\t"+ items[1]+"\t"+items[2] #+"\t"+ items[3]
outfile.write(dataline +"
")
aline = infile.readline()
print(aline)
infile.close()
outfile.close()
####
#create a fourth column in excel called average while using python

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!