# Meanvalue.py (c) 1997-2006 Kari Laitinen
# http://www.naturalprogramming.com
# 2006-04-13 File created.
# 2006-05-27 Last modification.
# The corresponding Java/C++/C# programs (e.g. Meanvalue.java)
# demonstrate the do-while loops of those langauges.
# The Python programming language does not have do-while loops.
# Hence, this program is written using a while loop.
integer_from_keyboard = -1
number_of_integers_given = -1
mean_value = 0.0
sum_of_integers = 0
print "\n This program calculates the mean value of" \
"\n the integers that you enter from the keyboard." \
"\n Please, start entering numbers. The program" \
"\n stops when you enter a zero. \n"
while integer_from_keyboard != 0 :
print " Enter an integer:",
integer_from_keyboard = int( raw_input() )
number_of_integers_given += 1
sum_of_integers = sum_of_integers + integer_from_keyboard
if number_of_integers_given > 0 :
mean_value = float( sum_of_integers ) / \
float( number_of_integers_given )
print "\n The mean value is: %f" % mean_value