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

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
>>>
主站蜘蛛池模板: 萨迦县| 白山市| 太仓市| 两当县| 吉木乃县| 鄂托克前旗| 日照市| 轮台县| 化隆| 天水市| 延庆县| 桂林市| 天台县| 黄山市| 慈利县| 昔阳县| 油尖旺区| 来凤县| 南陵县| 河西区| 兴文县| 澄城县| 怀仁县| 芦溪县| 田林县| 洛宁县| 双江| 固阳县| 嘉祥县| 灵丘县| 阿拉善右旗| 诸暨市| 富锦市| 苗栗市| 治县。| 甘德县| 独山县| 昌平区| 龙门县| 佛冈县| 忻城县|