日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python逻辑运算符的使用_总结Python中逻辑运算符的使用

發(fā)布時(shí)間:2023/12/2 python 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python逻辑运算符的使用_总结Python中逻辑运算符的使用 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

下表列出了所有python語言支持的邏輯運(yùn)算符。假設(shè)變量a持有10和變量b持有20,則:

示例:

試試下面的例子就明白了所有的python編程語言提供了邏輯運(yùn)算符:

#!/usr/bin/python

a = 10

b = 20

c = 0

if ( a and b ):

print "line 1 - a and b are true"

else:

print "line 1 - either a is not true or b is not true"

if ( a or b ):

print "line 2 - either a is true or b is true or both are true"

else:

print "line 2 - neither a is true nor b is true"

a = 0

if ( a and b ):

print "line 3 - a and b are true"

else:

print "line 3 - either a is not true or b is not true"

if ( a or b ):

print "line 4 - either a is true or b is true or both are true"

else:

print "line 4 - neither a is true nor b is true"

if not( a and b ):

print "line 5 - either a is not true or b is not true"

else:

print "line 5 - a and b are true"

當(dāng)執(zhí)行上面的程序它會(huì)產(chǎn)生以下結(jié)果:

line 1 - a and b are true

line 2 - either a is true or b is true or both are true

line 3 - either a is not true or b is not true

line 4 - either a is true or b is true or both are true

line 5 - either a is not true or b is not true

如您對(duì)本文有疑問或者有任何想說的,請(qǐng)點(diǎn)擊進(jìn)行留言回復(fù),萬千網(wǎng)友為您解惑!

總結(jié)

以上是生活随笔為你收集整理的python逻辑运算符的使用_总结Python中逻辑运算符的使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。