Question: Description: Write a program called StudentGrades using lists and loops to ask for student name and 3 test scores. Calculate the average of the test

Description: Write a program called StudentGrades using lists and loops to ask for student name and 3 test scores.

Calculate the average of the test scores and assign a letter score as follows:

>90 A

80 - 89 B

70 - 79 C

60 - 69 D

<60 F '''

# make empty list that will be filled later studentName = [ ] score1 = [ ] score2 = [ ] score3 = [ ] average = [] grade = [ ]

test_score = 0.0

amountStudents = int(input("How many students? ")) for s in range(0, amountStudents): # ask user to input student name 1 name = input("Enter name of student " +str(s+1) + ":" ) # add this to empty list studentName.append(name)

for s in range(0, amountStudents): enterScore = input('Enter test 1 for ' + studentName[s] + ': ') score1.append(float(enterScore)) enterScore = input('Enter test 2 for ' + studentName[s] + ': ') score2.append(float(enterScore)) enterScore = input('Enter test 3 for ' + studentName[s] + ': ') score3.append(float(enterScore))

for s in range (0, amountStudents): test_score = 0.0 test_score = float(test_score + score1[s] + score2[s] + score3[s]) test_average = float(test_score / 3.0) average.append(float(test_average)) if (average [s] > int(90)): # add to grade list and assign A for this condition grade.append("A") elif (int(80) <= test_average [s] <= int(89)): grade.append("B") elif (int(70) <= test_average [s] <= int(79)): grade.append("D") elif (test_average[s] < int(60)): grade.append("F")

# for loop to print test average and final grade for s in range(0, amountStudents): final_average = studentName[s] + "'s test average: " + format(average[s], '.2f') print(final_average) final_grade = studentName[s] + "'s final grade: " + grade[s] print(final_grade)

elif (int(80) <= test_average [s] <= int(89)): TypeError: 'float' object is not subscriptable

I have no idea how to fix it.

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!