# Whilesum.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-02-24 File created. # 2006-05-27 Last modification. # A comma at the end of the print statement specifies # that a newline should not be printed after the printing operation. integer_from_keyboard = -1 sum_of_integers = 0 print "\n This program calculates the sum of the integers" \ "\n you type in from the keyboard. By entering a" \ "\n zero you can terminate the program. \n" while integer_from_keyboard != 0 : print " Current sum: %8d Enter an integer: " % sum_of_integers, integer_from_keyboard = int( raw_input() ) sum_of_integers = sum_of_integers + integer_from_keyboard