16-bool 与位运算:& 与 and 的区别

16-bool 与位运算:& 与 and 的区别

语法讲解 今天学: & 与 and print(True & False) print(True and False) 小练习 运行下面代码后输出是什么?(多行输出请按真实换行

阅读更多 →
15-and 也返回操作数本身

15-and 也返回操作数本身

语法讲解 今天学: and 的返回值规则 print(0 and 5) print(2 and 5) 小练习 运行下面代码后输出是什么?(多行输出请按真实换行提交) print(0 and 5

阅读更多 →
14-or 返回的不是 bool(返回操作数本身)

14-or 返回的不是 bool(返回操作数本身)

语法讲解 今天学: or 的返回值规则 print(0 or 2) print(0 or 0) 小练习 运行下面代码后输出是什么?(多行输出请按真实换行提交) print(0 or 2) pr

阅读更多 →
13-bool(list/tuple/dict):空为 False

13-bool(list/tuple/dict):空为 False

语法讲解 今天学: 容器的真值测试 print(bool([])) print(bool([0])) print(bool({})) print(bool({"a": 0}))

阅读更多 →
12-float(True/False)

12-float(True/False)

语法讲解 今天学: bool 转 float print(float(True)) print(float(False)) 小练习 运行下面代码后输出是什么?(多行输出请按真实换行提交) pr

阅读更多 →
11-True is 1 吗?(身份 vs 相等)

11-True is 1 吗?(身份 vs 相等)

语法讲解 今天学: is 与 == print(True is 1) print(True == 1) 小练习 运行下面代码后输出是什么?(多行输出请按真实换行提交) print(True i

阅读更多 →
10-True/False 与 1/0 的相等性

10-True/False 与 1/0 的相等性

语法讲解 今天学: bool 与 int 的相等关系 print(True == 1) print(False == 0) 小练习 运行下面代码后输出是什么?(多行输出请按真实换行提交) pr

阅读更多 →
09-比较运算返回 bool,但可参与运算

09-比较运算返回 bool,但可参与运算

语法讲解 今天学: 比较结果的数值性 print((3 > 2) + (2 > 3)) 小练习 运行下面代码后输出是什么? print((3 > 2) + (2 > 3

阅读更多 →
08-字符串转 bool:别用 bool(s)

08-字符串转 bool:别用 bool(s)

语法讲解 今天学: 字符串真值测试陷阱 s = "False" print(bool(s)) 小练习 运行下面代码后输出是什么? s = "False"

阅读更多 →
07-int('True') 能转吗?

07-int('True') 能转吗?

语法讲解 今天学: int() 解析字符串的限制 try: print(int("True")) except Exception as e: print(type

阅读更多 →