Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What are the Python codes for these two questions? string) and an output csv fil

ID: 3706699 • Letter: W

Question

What are the Python codes for these two questions?

string) and an output csv filename (a string), where the input csv filename is the name of a file that exists and the output csv filename is the name of the file you will write your output to. Your function should create a copy of the input csv file with an extra column containing each student's test average. Your function should not return anything How to test: # call inside main() write_with_averages( 'random_grades.csv', 'grades_and_averages.csv') There will be no output, but now a file named grades_and_averages.csv should exists in the same folder where random grades.csv is located and should contain the following Name,Test1,Test2,Test3,Average lla, 1,67,64,44.0 Xavier,83,11,54,49.333333333333336 Phillip,39,95,16,50.0

Explanation / Answer

%for 1 def write_with_averages(read,write): fout=open(write,'w') first=True with open(read,'r') as fin: for line in fin: line=line.strip() if first: line=line+',Averages' first=False else: L=line.split(',') avg=(float(L[1])+float(L[2])+float(L[3]))/3 line=line+','+str(avg) fout.write(line) fout.write(' ') fout.close() %for 2 def safe_list_indexing(array,index): try: return array[index] except IndexError: return 'The given index is invalid'

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote