Answer to Question #136136 in Python for claire

Question #136136
You want to know your grade in Computer Science, so write a program that continuously takes grades between 0 and 100 to standard input until you input "stop", at which point it should print your average to standard output.
1
Expert's answer
2020-10-01T14:49:11-0400
# the variable to store count

scoresCount = 0

# the variable to store scores sum

scoreSum = 0

# the variable to store the input

inp = ''

# user prompt

print("Please inp the grades one by one, inp 'stop' to quit")

# repeat while input is not stop

while inp != "stop":

    inp = input('Enter the grade:')

    # if input is not stop and is a number

    if inp != "stop" and inp.isdigit():
        # add the input grade to the sum

        scoreSum += int(inp)

        # increment the scores count

        scoresCount = scoresCount + 1

# print the average to standard output

print("The average of entered grades is: ")

print(float(scoreSum) / scoresCount)

Output:






Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS