Creating a Test and Debug Plan Quick Check 3 of 53 of 5 Items Question The following program is supposed to find the average of five grades. 1 sum = 0 2 for x in range(0,5): 3 temp = float(input("Grade: ")) 4 sum = temp + 1 5 6 grade = sum / 5 7 print("Grade = " + str(grade)) But the average is not printing out correctly. A sample run looks as given below. Grade: 100 Grade: 67 Grade: 89 Grade: 92 Grade: 81 Grade = 16.4 ** Process exited - Return Code: 0 ** Press Enter to exit terminal To find the error which variable would be most appropriate to print out to debug the program? (1 point) Responses grade grade temp temp sum sum x x Skip to navigation page 5 of 5

1 answer

To debug the program effectively, the most appropriate variable to print out would be sum.

The issue lies in the line sum = temp + 1, which incorrectly calculates the sum of grades by always adding 1 to the grade entered instead of accumulating the total. Printing sum after the loop will help determine if it is being calculated correctly. Here’s how the relevant part of the code would look with added debug output:

sum = 0
for x in range(0, 5):
    temp = float(input("Grade: "))
    sum = sum + temp  # Correct way to add the grade to the total
print("Current sum: ", sum)  # Debug output

This way, you can see the sum after all grades are entered and identify if it matches your expectation.