58.2k views
0 votes
In python:

Assign sum_extra with the total extra credit received given list test_grades. Full credit is 100, so anything over 100 is extra credit. For the given program, sum_extra is 8 because 1 + 0 + 7 + 0 is 8.

Sample output for the given program with input: '101 83 107 90'

Sum extra: 8

User Lbstr
by
5.2k points

1 Answer

6 votes

Answer:

test_grades = []

tryagain = 'y'

while tryagain.lower() == 'y':

grade = int(input("Grade: "))

test_grades.append(grade)

tryagain = input("Another Input: ")

sum_extra = 0

for i in test_grades:

if i > 100:

sum_extra = sum_extra + (i - 100)

print(sum_extra)

Step-by-step explanation:

This line initializes an empty list test_grade

test_grades = []

This line prepares the user for input

tryagain = 'y'

The following iteration is repeated until the user stops input

while tryagain.lower() == 'y':

This prompts the user for grade

grade = int(input("Grade: "))

This appends the grade to the list

test_grades.append(grade)

This asks if there is another grade to be input

tryagain = input("Another Input: ")

This initializes sum_extra to 0

sum_extra = 0

This iterates through test_grade

for i in test_grades:

The following if condition gets the grades greater than 100 and sums the extra credit

if i > 100:

sum_extra = sum_extra + (i - 100)

This prints the extra credit

print(sum_extra)

User Double AA
by
5.4k points