zoukankan      html  css  js  c++  java
  • python语句

    基本逻辑运算符(if ...elif...else)(0,False,None为假)

    flag = False
    name = 'luren'
    if name == 'python':         # 判断变量否为'python'
        flag = True          # 条件成立时设置标志为真
        print('welcome boss')    # 并输出欢迎信息
    else:
        print(name)              # 条件不成立时输出变量名称
     1 num = 5     
     2 if num == 3:            # 判断num的值
     3     print('boss')        
     4 elif num == 2:
     5     print('user')
     6 elif num == 1:
     7     print('worker')
     8 elif num < 0:           # 值小于零时输出
     9     print('error')
    10 else:
    11     print('roadman')     # 条件均不成立时输出
     1 num = 9
     2 if num >= 0 and num <= 10:    # 判断值是否在0~10之间
     3     print('hello')
     4 # 输出结果: hello
     5  
     6 num = 10
     7 if num < 0 or num > 10:    # 判断值是否在小于0或大于10
     8     print('hello')
     9 else:
    10     print('undefine')
    11 # 输出结果: undefine
    12  
    13 num = 8
    14 # 判断值是否在0~5或者10~15之间
    15 if (num >= 0 and num <= 5) or (num >= 10 and num <= 15):    
    16     print('hello')
    17 else:
    18     print('undefine')
    19 # 输出结果: undefine
    age = 16
    high = 170
    success = True
    
    if age:
        print('ok')
    else:
        print('不OK')
    
    if age > 17:
        if success:
            print('咱们结婚吧!')
        else:
            print('去他妈的爱情!')
    elif high > 160:
        print('你好高')
    else:
        print('不表白')
     score=input('>>: ')
     > 90:优秀
     80 < 90 :良好
     >=60 <80 :合格
     <60:滚犊子
    
    
     score = int(input('请输入你的成绩:'))
     if score > 90:
         print('优秀')
     elif score > 80 and score <= 90:
         print('良好')
     elif score >=60 and score < 80:
         print('合格')
     else:
         print('滚犊子')
  • 相关阅读:
    pstree
    gvisor vfs2
    gvisor entersyscall exitsyscall
    gvisor在arm64下syscall.SIGILL信号处理
    SpringBlade 为id添加自增长属性
    SQL Server Update 一个列的数据为随机数
    SpringBlade Saber 关闭验证码
    SpringBlade Saber 用户列表的新增按钮 是怎么个显示原理
    SpringBlade Saber 切换标签页 不刷新
    SpringBlade 00 常见问题汇总
  • 原文地址:https://www.cnblogs.com/wangxudong/p/10057604.html
Copyright © 2011-2022 走看看