Python while loop

paul.garcia2345 at gmail.com paul.garcia2345 at gmail.com
Tue Nov 29 18:58:54 EST 2016


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" ??



More information about the Python-list mailing list