On 29/11/2016 23:58, [email protected] wrote:
Write a program which prints the sum of numbers from 1 to 101 ( 1 and 101 are included) that are divisible by 5 (Use while loop)This is the code: x=0 count=0 while x<=100: if x%5==0: count=count+x x=x+1 print(count)
This looks at numbers from 0 to 100 inclusive, not 1 to 101. Although it doesn't affect the result. (It will add in 0 which is divisible by 5, but that doesn't change it either. If this is an exercise however, checking the correct range might be important!)
-- Bartc -- https://mail.python.org/mailman/listinfo/python-list
