zoukankan      html  css  js  c++  java
  • python 分支语句 循环语句

    分支语句

    #if-else
        if a > b:
            print('aaa')
        else:
            print('bbb')
    
    #if-elif-else
        if a > b:
            print('a>b')
        elif a == b:
            print('a==b')
        else:
            print('a<b')

    循环语句

    while 判断条件:
        执行语句
    for temp in sequence:
        执行语句
    #-*- coding:utf-8 -*-
    for letter in 'python':
      
    print('current letter is %s'%letter)
    #-*- coding:utf-8 -*-
    fruits = ['banner','apple','orange']
    for fruit in fruits:
         print('current fruit is %s'%fruit)                                        

     Python中for else 语句 只要for循环语句不是通过break结束循环,那么无论for循环有没有执行,都会执行else里的语句. while ...else也是一样

    break:跳出整个循环

    continue:跳出本次循环,继续执行下一次循环

  • 相关阅读:
    LabVIEW入门第三天(软件及驱动包下载)
    poj1732
    poj1722
    poj1821
    poj1770
    poj1949
    poj1726
    poj1699
    poj1682
    poj1853
  • 原文地址:https://www.cnblogs.com/wgDream/p/6679635.html
Copyright © 2011-2022 走看看