布尔值
布尔值:True和False
作用:True和False就像开关一样决定for…in语句和while循环语句是否运行
布尔运算的三种方式
1.两个数值比较
password = input('请输入密码:')
if password == 'abc':
print('密码正确!')
else:
print('密码错误!')
2.直接用数值做运算
python中的真假判断
if False:
print('False')
if True:
print('True')
《True
if 1: ~#使用了条件判断的代码,因为终端打印出了'熊猫',说明 if 后面的条件为真
print('熊猫')
《 熊猫
3.布尔值之间的运算
你会接触到and、or、not、in、not in五种运算
a = 5
b = -1
c = 0
d = 7
if a<b and c<d:
print('True')
else:
print('False')