运算符的比较
获取对象布尔值
print(bool(False))
print(bool(0))
print(bool(0.0))
print(bool(None))
print(bool(''))
print(bool([]))
print(bool(list()))
print(bool(()))
print(bool(tuple()))
print(bool({}))
print(bool(dict()))
if的使用
money=1000
s=int(input('请输入你要取款的金额:'))
''''
if money >= s:
money-=s
print('取款成功,余额为',money)
else:
print('钱不够')
'''
if money>s:
money-=s
print('取款成功,余额为',money)
elif money==s:
print('The all money you hava is here.')
else:
print('The money you have is not enough.')
占位符
if 1>2:
pass
else:
pass
range()函数
'''第一种 range(x) [0,x)步长为1'''
r=range(10)
print(r)
print(list(r))
print(10 in r)
'''第二种 range(x,y) [x,y)步长为1'''
r=range(2,10)
print(list(r))
'''第三种 range(x,y,z) [x,y)步长为z'''
r=range(2,10,2)
print(list(r))
|