# Nico # 时间:2021/4/20 20:43 # 循环结构,while循环 ''' 语法结构: while 条件表达式: 条件执行体(循环体) ''' a = 1 while a < 10: print(a) a += 1 # 求1到100之间的奇数、偶数之和 a = 1 sum = 0 sum1 = 0 # 初始化变量 while a <= 100: # 条件判断 if a % 2 == 0: # 条件执行体(求和) sum += a if a % 2: sum1 += a a += 1 # 改变变量 print(sum) print(sum1)