Friday, 20 September 2013

working loops and while range

for letter in 'python':
    print 'current letter:',letter


#create a list called colors
   
colors=['pink','lermongreen','purpule','blue','yellow','orange']
for h in colors:
    print h,'is your favorite color'
   
   
#using range function
for a in range(10):
    print (a)
   
for x in xrange(30):
    if x % 2==0:
        continue
    print x
for y in range(20):
    if y %2!=0:
        continue
    print y
   
for x in xrange(500,599):
     if x %2!=0:
         continue
     print x
       
    
#working with while loops
count=0
while (count < 9):
    print 'the count is :' ,count
    count= count +1

count=11
while (count < 11):
    print 'the count is :' ,count
    count= count +1
   
mars=11
while (mars <35):
    print 'this number is  not greater than:',mars
    mars=mars+1
    
    
   
       
   

No comments:

Post a Comment