zoukankan      html  css  js  c++  java
  • if语法

    语法一:
      if 条件:   条件成立时执行的子代码块

       

    age_of_girl=31
    if age_of_girl > 30:
        print('阿姨好')

    语法二:if + else  
      if 条件:  条件成立时执行的子代码块

        代码....

      else:      条件不成立时执行的子代码块

        代码...

    age_of_girl=18
    if age_of_girl > 30:
        print('阿姨好')
    else:
        print('小姐好')

    语法三:if + if

      if 条件1:

        if 条件2:

          代码xxx

    sex='female'
    age=18
    is_beautiful=True
    is_successful=True
    height=1.70
    if sex == 'female' and age > 16 and age < 20 and is_beautiful 
            and height > 1.60 and height < 1.80: 
        print('开始表白。。。')
        if is_successful:
            print('在一起。。。')

    语法四:if + elif +elif +else

        if 条件:

          代码。。。。
        elif 条件:
          代码....
        elif 条件:
          代码。。。
        else 条件:
          代码,,,

    score=input('>>: ')
    score=int(score)
    
    if score >= 90:
        print('优秀')
    elif score >= 80:
        print('良好')
    elif score >= 70:
        print('普通')
    else:
        print('很差')
  • 相关阅读:
    Redis——发布/订阅
    Redis——任务队列
    GOF设计模式——Builder模式
    GOF设计模式——Prototype模式
    GOF设计模式——Singleton模式
    shell 脚本中的数学计算表达
    shell $'somestring'
    shell if-elif-elif-fi
    vim 使用
    疑问:为什么要使用href=”javascript:void(0);”?
  • 原文地址:https://www.cnblogs.com/lakei/p/10574108.html
Copyright © 2011-2022 走看看