Tuesday, 23 May 2017

python - example "for while loop" for addtion and substration

a = 1
s = 0
print('enter number to add to the sum')
print ('enter 0 to quit')

while a != 0:
    print('current sum', s)
    a = float(input('no.?     '))
    s = s + a
    print ('total sum =  ' ,s)

No comments:

Post a Comment