Ask Question
6 January, 10:16

Create a program that asks the user to enter grade scores. Use a loop to request each score and add it to a total. Continue accepting scores until the user enters a negative value. Finally, calculate and display the average for the entered scores.

+3
Answers (1)
  1. 6 January, 11:23
    0
    total = 0

    count = 0

    while (True):

    grade = float (input ("Enter a grade: "))

    if grade < 0:

    break

    else:

    total + = grade

    count + = 1

    average = total/count

    print ("The average is: " + str (average))

    Explanation:

    *The code is in Python.

    Initialize the total and count as 0

    Create a while loop that iterates until a specific condition is met inside the loop

    Inside the loop, ask the user to enter a grade. If the grade is smaller than 0, stop the loop. Otherwise, add the grade to the total and increment the count by 1.

    When the loop is done, calculate the average, divide the total by count, and print it
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Create a program that asks the user to enter grade scores. Use a loop to request each score and add it to a total. Continue accepting ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers