Answer:
def finalGrade(scoresList):
""" Function that finds the final grade """
hw1_weighted = float(scoresList[0])/10 * 0.05
hw2_weighted = float(scoresList[1])/10 * 0.05
mid_weighted = float(scoresList[2])/100 * 0.40
fin_weighted = float(scoresList[3])/100 * 0.50
final_grade = (hw1_weighted + hw2_weighted + mid_weighted + fin_weighted) * 100
return final_grade
if __name__ == '__main__':
''' Reading and processing scores '''
# Reading names from text file
names = []
# Opening text file
with open("d:\\Python\\\ames.txt", "r") as fp:
# Reading data
for line in fp:
# Stripping new line
line = line.strip()
# Adding to list
names.append(line)
# Reading scores
finalGrades = []
# Reading scores
with open("d:\\Python\\scores.csv", "r") as fp:
# Reading data
for line in fp:
# Stripping new line
line = line.strip()
# Scores list
scores = []
# Iterating over scores
for score in line.split(','):
# Adding to list
scores.append(score)
# Finding grade
grade = finalGrade(scores)
# Adding to list
finalGrades.append(grade)
# Printing result
for i in range(len(names)):
print("\\%s earned %.1f%%"%(names[i], finalGrades[i]))
Step-by-step explanation:
This program was implemented with python programming language.
This program will read the scores from the CSV file, pass the scores as a list to the finalGrade function, and display the resulting final grade, along with the student's name.
See attachment for screenshots