标签:就是 否则 pytho 返回 运算符 class NPU 等于 lse
print (3 != 3) #print(3 <> 3) #不等于 版本取消 print(3 >= 2) a = 10 b = a # 把a的值 赋值给变量b c = a print(b) print(c) a = 10 b = 20 a += b #a = a + b 累加 sum = sum + count sum += count print(a) print(b) count = 1 while count <= 100: print(count) #count = count + 1 count += 1 ‘‘‘ and:并且,左右两端同时为真,结果才能是真 or:或者,左右两端有一个是真,结果就是真 not:非,非真既假,非假既真 不真->假 不假->真 ‘‘‘ print(3 > 2 and 4 < 6 and 5 > 7) #False print(5 < 6 or 7 < 8 or 9 < 6 or 3 >2) print(not 5 < 6) # 混合运算 # 运算顺序: () => not => and => or 当出现相同的运算的时候 从左往右算 print(3 > 2 or 5 < 7 and 6 > 8 or 7 < 5) #true # 当出现 x or y 的时候,判断x是否是0 如果x==0 then y 否则返回x print(1 or 2) #1 print(0 or 2) #2 print(3 or 0) print(4 or 0) # print(3 or 0 or 2 or 1 or 8 or 188) print(0 or 3 or 0 or 2 or 0 or 8 or 0 or 188) #当出现x and y 的时候, 和or相反 print(1 and 2) #2 print(0 and 3) #0 print(3 and 0) print(4 and 0) # print(9 and 3 and 4 and 1 and 4 and 8) print(1 and 2 or 3) print(1 and 2 > 4) #False 当成0来看 print(False and 1) print(3 > 5 or 5 < 6 and 7) print(4 > 5 or 7 and 8 < 6 or 3 and 4) # 成员运算 content = input("请输入你的评论:") if "马化腾" in content: #content 中是否包含了xxx print("你的评论不合法") else: print("你的评论是不合法的") ad = input("请输入你的评论:") if "最" in ad or "第一" in ad or "全球" in ad: #or是只要出现 and是都出现 print("不合法的") else: print("合法的")
标签:就是 否则 pytho 返回 运算符 class NPU 等于 lse
原文地址:https://www.cnblogs.com/demons97/p/10028552.html