On 2016-11-29 23:58, paul.garcia2...@gmail.com 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)
Question: How does python know what count means ? I see that its declared. What i wanna
know is how does it know the iteration or each number it finds divisible by 5 is the
"Count" ??
It doesn't, it's just a name, and, anyway, in the code, 'x' is the count...
If it _did_ know (which is doesn't), wouldn't it be complaining that
'count' isn't the count but the sum? :-)
--
https://mail.python.org/mailman/listinfo/python-list