- Hands-On Data Science and Python Machine Learning
- Frank Kane
- 143字
- 2021-07-15 17:15:03
Understanding boolean expressions
Boolean expression syntax is a little bit weird or unusual, at least in Python:
print (1 == 3)
The output of the above code is as follows:
False
As usual, we have the double equal symbol that can test for equality between two values. So does 1 equal 3, no it doesn't, therefore False. The value False is a special value designated by F. Remember that when you're trying to test, when you're doing Boolean stuff, the relevant keywords are True with a T and False with an F. That's a little bit different from other languages that I've worked with, so keep that in mind.
print (True or False)
The output of the above code is as follows:
True
Well, True or False is True, because one of them is True, you run it and it comes back True.
推薦閱讀
- 基于粒計算模型的圖像處理
- The Android Game Developer's Handbook
- Microsoft Dynamics 365 Extensions Cookbook
- Vue.js前端開發基礎與項目實戰
- 假如C語言是我發明的:講給孩子聽的大師編程課
- Java程序設計與實踐教程(第2版)
- HTML5 and CSS3 Transition,Transformation,and Animation
- HTML5+CSS3+JavaScript Web開發案例教程(在線實訓版)
- Hands-On Microservices with Kotlin
- QGIS:Becoming a GIS Power User
- Odoo 10 Implementation Cookbook
- OpenStack Networking Essentials
- Django 5企業級Web應用開發實戰(視頻教學版)
- STM8實戰
- Photoshop智能手機APP界面設計