# 条件判断与循环 ## 学习目标 - 掌握 if-elif-else 条件判断 - 学会使用 for 循环 - 掌握 while 循环 ## 条件判断 ```python age = 18 if age < 18: print("未成年人") elif age < 60: print("成年人") else: print("老年人") ``` ## for 循环 ```python # 遍历列表 fruits = ["apple", "banana", "cherry"] for fruit in fruits: print(fruit) # 使用 range for i in range(5): print(i) # 输出 0, 1, 2, 3, 4 ``` ## while 循环 ```python count = 0 while count < 5: print(count) count += 1 ``` ## 循环控制 - `break` - 跳出循环 - `continue` - 跳过当前迭代 ## 动手练习 1. 编写程序判断奇偶数 2. 使用循环打印乘法表 3. 计算 1 到 100 的和