分支语句 #if-else if a > b: print('aaa') else: print('bbb') #if-elif-else if a > b: print('a>b') elif a == b: print('a==b') else: print('a<b') 循环语句 while 判断条件: 执行语句 for temp in sequence: 执行语句 #-*- coding:utf-8 -*- for letter in 'python': print('cu…
一.if else语句 if 条件表达式: else: a = 3 b = 4 if a >= b: print("a >= b") else: print("a < b") 二.if elif else a = 6 b = 6 if a > b: print("a > b") elif a < b: print("a < b") else: print("a = b&quo…
Python的分支语句比较简单,只有if.else.elif三个关键字,也就是说,Python没有switch语句,而且,Python中并没有?:这个三目运算符. 例子: age = 18 if age < 18: print('too young') elif age == 18: print('ok') else: print('too old') 结果输出为ok…