Analysis of examination results. : While « Language Basics « Python






Analysis of examination results.

 



passes = 0                  # number of passes
failures = 0                # number of failures
studentCounter = 1          # student counter

while studentCounter <= 10:
   result = raw_input( "Enter result (1=pass,2=fail): " )
   result = int( result )   # one exam result

   if result == 1:
      passes = passes + 1
   else:
      failures = failures + 1

   studentCounter = studentCounter + 1

print "Passed", passes
print "Failed", failures

if passes > 8:
   print "Raise tuition"

           
         
  








Related examples in the same category

1.While loop with counter-controlled repetition.While loop with counter-controlled repetition.
2.While loop with sentinel-controlled repetiton.While loop with sentinel-controlled repetiton.
3.Use if inside whileUse if inside while
4.While loopWhile loop
5.How to use whileHow to use while
6.While loop demoWhile loop demo
7.While with breakWhile with break
8.Write an initial sub-sequence of the Fibonacci series
9.While with elseWhile with else
10.Guess My Number
11.A trailing comma avoids the newline after the output