python流程控制

4.流程控制和循环

age = raw_input('age:')
if  age>40:
    print  'old!'
elif  age>30:
    print  'young!'
else:
    print 'younger!'
if执行到情况匹配时就直接结束,并不是退出
else也可以省略
变量的声明等号  = 
赋值的定义是双等号   == 
 
for循环
for  *  in  * :
 

5.while循环

while循环默认是死循环
for循环有起始结束,循环次数
 
print_num = input('which loop do you want it to be printed out?')
count = 0
while count < 100000:
       if count == print_num:
            print 'There you got  the number:',count
            choice = raw_input('Do you want to continue the loop?(y/n)')
            if choice == 'n':
                 break
            else:
                  while print_num <= count:
                         print_num = inout('Which loop do you want it to be printed out?')
                         print u"pass"
       else:
              print 'Loop:',count
       count  +=1      
 
else:
      print 'loop:',count
原文地址:https://www.cnblogs.com/muzinan110/p/4919676.html