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

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
>>>
主站蜘蛛池模板: 盈江县| 磐石市| 天全县| 大厂| 滁州市| 江山市| 潍坊市| 寿宁县| 绵阳市| 镇坪县| 定结县| 措勤县| 象州县| 太康县| 金溪县| 吴江市| 泰顺县| 溧阳市| 玛多县| 德阳市| 鹰潭市| 临城县| 白玉县| 兴仁县| 湖口县| 桑日县| 万载县| 大足县| 临泉县| 隆回县| 乌鲁木齐县| 寻甸| 鄄城县| 荃湾区| 华亭县| 阿拉善左旗| 日照市| 永川市| 沙河市| 黄浦区| 昌图县|