69,489 views
3 votes
3 votes
16.44 Lab 13D: Student Scores with Files and Functions Overview Create a program that reads from multiple input files and calls a user-defined function. Objectives Gain familiarity with CSV files Perform calculations with data from CSV files Create a user-defined function Read from multiple files in the same program

User CZahrobsky
by
3.5k points

1 Answer

0 votes
0 votes

Answer:

See Explaination

Step-by-step explanation:

# copy the function you have this is just for my convenniece

def finalGrade(scoresList):

weights = [0.05, 0.05, 0.40, 0.50]

grade = 0

for i in range(len(scoresList)):

grade += float(scoresList[i]) * weights[i]

return grade

import csv

def main():

with open('something.csv', newline='') as csvfile:

spamreader = csv.reader(csvfile, delimiter=',', quotechar='|')

file = open('something.txt')

for row in spamreader:

student = file.readline().strip()

scores = row

print(student, finalGrade(scores))

if __name__ == "__main__":

main()

User Newtopian
by
2.8k points