While loop with counter-controlled repetition. : While : Language Basics PYTHON examples


PYTHON examples » Language Basics » While »

 

While loop with counter-controlled repetition.


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 = intgrade )                 # convert string to an integer
   total = total + grade
   gradeCounter = gradeCounter + 1

average = total / 10                    # integer division
print "Class average is", average

           
         
  



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Language Basics
» While