Python 运算符,,print (3 !


print (3 != 3)#print(3 <> 3) #不等于  版本取消print(3 >= 2)a = 10b = a # 把a的值 赋值给变量bc = aprint(b)print(c)a = 10b = 20a += b #a = a + b 累加 sum = sum + count  sum += countprint(a)print(b)count = 1while count <= 100:    print(count)    #count = count + 1    count += 1‘‘‘and:并且,左右两端同时为真,结果才能是真or:或者,左右两端有一个是真,结果就是真not:非,非真既假,非假既真 不真->假  不假->真‘‘‘print(3 > 2 and 4 < 6 and 5 > 7)  #Falseprint(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 否则返回xprint(1 or 2)  #1print(0 or 2)  #2print(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) #2print(0 and 3) #0print(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("合法的")

  

Python 运算符

评论关闭