python流程控制
python的流程控制day(04) 1.python的缩进 python 中的代码块不是使用{}来控制范围的,必须使用相同数目的行首缩进空格数,建议在每个缩进层次使用单个制表符或两个空格或四个空格, 不能混用. 2.if语句 格式: if 判断条件: 执行语句…… else: 执行语句…… 其中"判断条件"成立时(非零),则执行后面的语句,而执行内容可以多行,以缩进来区分表示同一范围。 else 为可选语句,当需要在条件不成立时执行内容则可以执行相关语句,具体例子如下: # if age > 16 and age < 30 and height > 160 and weight < 100 and sex=='female': # print('表白') elif的效果和其它语言类似,具体例子如下: # score = input('>>>') # score = int(score) # if score>90: # print('成绩优秀') # elif score>=80: # print('良好') # elif sco...
