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

  • 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
>>>
主站蜘蛛池模板: 麟游县| 沙田区| 屏东县| 日喀则市| 台山市| 辽宁省| 合川市| 哈尔滨市| 贞丰县| 林甸县| 中牟县| 松潘县| 临城县| 湖州市| 乐都县| 卢湾区| 仙居县| 宁城县| 仙游县| 邹平县| 阿巴嘎旗| 平和县| 阿合奇县| 利津县| 普兰店市| 海南省| 喜德县| 安多县| 个旧市| 蒲城县| 石楼县| 镇安县| 琼结县| 息烽县| 防城港市| 赣州市| 新安县| 西乡县| 漯河市| 靖宇县| 佛坪县|