習(xí)題 28 布爾表達(dá)式練習(xí)

習(xí)題 28 布爾表達(dá)式練習(xí)

>>> True and True
True
>>> False and True
False
>>> 1 == 1 and  2 == 1
False
>>> "test" == "test"
True
>>> 1 == 1 or 2 != 1
True
>>> True and 1 == 1
True
>>> False and 0 != 0
False
>>> True or 1 == 1
True
>>> "test" == "testing"
False
>>> 1 != 0 and 2 == 1
False
>>> "test" != "testing"
True
>>> "test" == 1
False
>>> not (True and False)
True
>>> not (1 == 1 and 0 != 1)
False
>>> not (10 == 1 or 1000 == 1000)
False
>>> not (1 != 10 or 3 == 4)
False
>>> not ("testing" == "testing" and "Zed" == "Cool Guy")
True
>>> 1 == 1 and not ("testing" == 1 or 1 == 0)
True
>>> "chunky" == "bacon" and not (3 == 4 or 3 == 3)
False
>>> 3 == 3 and not ("testing" == "testing" or "Python" == "Fun")
False

Python 和很多語言一樣,都是返回兩個被操作對象中的一個,而非它們的布爾表達(dá)式 TrueFalse。

>>> "test" and "test"
'test'
>>> 1 and 1
1
>>> False and 1
False
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 笨方法學(xué)python電子書里下面習(xí)題27-34 習(xí)題27:記住邏輯關(guān)系; --coding:utf-8-- 練習(xí)2...
    duduxuam閱讀 653評論 1 1
  • 第5章 引用類型(返回首頁) 本章內(nèi)容 使用對象 創(chuàng)建并操作數(shù)組 理解基本的JavaScript類型 使用基本類型...
    大學(xué)一百閱讀 3,663評論 0 4
  • 最近在寫個性化推薦的論文,經(jīng)常用到Python來處理數(shù)據(jù),被pandas和numpy中的數(shù)據(jù)選取和索引問題繞的比較...
    shuhanrainbow閱讀 4,700評論 6 19
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,506評論 19 139
  • 堅(jiān)持這條路上并不擁擠,因?yàn)槟軋?jiān)持下來的人,真不多。是的,哪怕再微小的事情,能一直堅(jiān)持走下去,都不容易。所以堅(jiān)持是一...
    鄉(xiāng)村田野閱讀 1,365評論 18 8

友情鏈接更多精彩內(nèi)容