#for loop
for letter in 'python':
print 'current letter:',letter
#creat a list of five colors
colors=['red','blue ','green','yellow','orange']
print colors
for green in 'favorite colors':
print 'favorite colors:',colors
#range
for a in range(20):
print(a)
#using xrange
for x in xrange(20):
print x
#using odd number in xrange
for x in xrange(30):
if x%2==0:
continue
print x
#using even number in xrange
for w in xrange(20):
if w%2!=0:
continue
print w
#counting from 500,600
for x in xrange(500,600):
print x
#working with while loop
count=0
while(count<9):
print 'the count is:', count
count=count+1
#using while loop
add=11
while(add<35):
print 'this is great then :',add
add=add+1
#
No comments:
Post a Comment