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


Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in Unknown on line 0