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. Instructor Notes: Make sure to initialize counter and total to 0 Read the grades between 0 and 100: grade = input() Use while loop as long as the grades input is not equal to "stop" Make sure to total int(grades) Increment counter by one input the grade again Finally, print the average: total/counter

Respuesta :

Answer:

The code is given below in python

# Code Block 1

count = 0  # count variable

total = 0  # total variable

enter = '' # input variable

while enter != 'stop':

   enter = input('Enter a grade:' )

   if enter != 'stop' and enter.isdigit():

       total += int(enter) # add to total value

       count = count + 1   # then to the count

print float(total) / count

# Code Block 2

numbers = []

while enter != 'stop':

   enter = input('Enter a grade:' )

   if enter != 'stop':

       numbers.append(int(enter))

print sum(numbers) / float(len(numbers))