啊啊啊啊啊吖

2018-11-19   阅读量: 550

数据分析师 Python编程 Python数据分析

Python里的for和while

扫码加入数据分析学习群

可以用 if 语句来执行一种有条件的行动:

if 1 > 2:
message = "if only 1 were greater than two..."
elif 1 > 3:
message = "elif stands for 'else if'"
else:
message = "when all else fails use else (if you want to)"

也可以在一行语句中使用 if-then-else,我们有时候需要这么做:

parity = "even" if x % 2 == 0 else "odd"

Python 也有 while 循环:

x = 0
while x < 10:
print x, "is less than 10"
x += 1

尽管我们更常用 for 和 in:

for x in range(10):
print x, "is less than 10"
添加CDA认证专家【维克多阿涛】,微信号:【cdashijiazhuang】,提供数据分析指导及CDA考试秘籍。已助千人通过CDA数字化人才认证。欢迎交流,共同成长!
0.0000 0 3 关注作者 收藏

评论(0)


暂无数据

推荐课程

推荐帖子