Contents

  1. sum5.py

sum5.py

# This program adds up 5 numbers from the user.
# By CS111, 09.20.2012

NUM_INPUTS = 9

print("This program will add up", NUM_INPUTS, "numbers given by the user.")

total = 0

for i in range(1, NUM_INPUTS+1):  # alternatively, for i in range(5):
    num = eval( input("Enter a number: ") )
    total += num
    
print("The total is", total)


Generated by GNU enscript 1.6.4.