While loop with counter-controlled repetition.

total = 0
gradeCounter = 1
while gradeCounter <= 10: # loop 10 times
grade = raw_input( "Enter grade: " ) # get one grade
grade = int( grade ) # convert string to an integer
total = total + grade
gradeCounter = gradeCounter + 1
average = total / 10 # integer division
print "Class average is", average
Related examples in the same category