官术网_书友最值得收藏!

  • Learning Python for Forensics
  • Preston Miller Chapin Bryce
  • 119字
  • 2021-08-20 10:17:02

Boolean and none

The integers 0 and 1 can also represent Boolean values in Python. These values are the Boolean False or True objects, respectively. To define a Boolean, we can use the bool() constructor statement. These data types are used extensively in program logic to evaluate statements for conditionals, as covered later in this chapter.

Another built-in data type is the null type, which is defined by the keyword None. When used, it represents an empty object, and when evaluated will return False. This is helpful when initializing a variable that may use several data types throughout execution. By assigning a null value, the variable remains sanitized until reassigned:

>>> bool(0)
False
>>> bool(1)
True
>>> None
>>>
主站蜘蛛池模板: 当涂县| 花莲县| 夹江县| 东乌珠穆沁旗| 错那县| 肇庆市| 南昌县| 兴业县| 信丰县| 苏尼特右旗| 出国| 文昌市| 阿城市| 奇台县| 孟州市| 左权县| 六枝特区| 建平县| 江门市| 安康市| 丰县| 沁阳市| 芜湖县| 海丰县| 文山县| 杭锦旗| 界首市| 南丰县| 桃源县| 黑水县| 巴东县| 即墨市| 青岛市| 平陆县| 手机| 青铜峡市| 米泉市| 米林县| 水富县| 乐业县| 利津县|