Tuesday, November 19, 2019

write a program in python to append all even number upto 100 which are divisible by 10

write a program in python to append all even number upto 100 which are divisible by 10

l=[]
for x in range(101) :
    if x%10==0:
        l.append(x)
    else:
        x=x+1
print(l)
 
output:
[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]

or
l=[]
for x in range(0,101,10) :
        l.append(x)
print(l)


output:
[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]

No comments:

Post a Comment

python class topic video