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;
    
    
    
    
                
  • 相关阅读:
    .net 中文显示乱码问题(Chinese display with messy code)
    Compare the value of entity field.
    人见人爱A^B 题解
    人见人爱A-B 题解
    全局变量
    第39级台阶 题解
    马虎的算式 题解
    做题技巧
    inline用法
    queue函数用法
  • 原文地址:https://www.cnblogs.com/airven/p/4937959.html
Copyright © 2011-2022 走看看