zoukankan      html  css  js  c++  java
  • python学习之控制语句

    #if statement
    number=int(input("please input a number"));
    if number<10 :
          print("is young");
    elif number>20:
          print("is yound older");
    else:
          print("any one else")
        
    #for statement
    _strlist=["fjfsjf'","apple","shje"];
    for item in _strlist:
          print(item);
    
    #for and if combine
    del(_strlist);
    tech=['a','b','c'];
    for item in tech[:]:
          if item=='c':
                tech.insert(0,item);
                tech.append("fff");
    print(tech);
    
    del(number);
    
    #range
    for i in range(4,15):
          print(i,end=',');
    
    for j in range(0,5,1):
          print(j,end='c');
          
    _myarra=['mary','lily','lamb'];
    for item in range(len(_myarra)):
          print(item,_myarra[item]);
    
    for i, v in enumerate(['tic', 'tac', 'toe']):
          print(i,v);
    
    #break
    for a in range(2,10):
          for b in range(2,a):
                if a%b==0:
                      print(a);
                      break;
                else:
                       print("no");
    
    #continue
    for num in range(2, 10):
          if num % 2 == 0:
               print("Found an even number", num);
               continue;
          print("Found a number", num);
    
    #pass
    while 1==1:
          pass;
    
    
    
    
                
  • 相关阅读:
    2、基础知识点回顾
    jQuery事件二
    71、auth模块、bbs项目关系表
    PYthon-4.26作业
    PYthon-线程
    PYthon-4.23作业
    PYthon-4.15作业
    PYthon-4.9作业
    PYthon-4.7作业
    PYthon-3.31作业
  • 原文地址:https://www.cnblogs.com/airven/p/4937959.html
Copyright © 2011-2022 走看看