三元运算
作用:提高代码效率
值1 if 条件 else 值2
示例1:
示例2:
2,pass 占位符,保证代码的完整性
3,for 循环 (有限循环) while -->无限循环
数字本身不是可迭代对象,想要自定义范围,可以借助于range函数
for i in range(100):
for i in range(0,100):
for i in range(0,100,1)
上述三种写法相同,默认不写开始,从0 开始,步长默认为1
也支持负数取值