Ask 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 scores until the user enters a negative value. Finally, calculate and display the average for the entered scores.

+4
Answers (1)
  1. Today, 04:11
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers