📘 学习目标

  • 掌握 for 循环与 while 循环的基本语法
  • 理解循环在数据处理中的应用场景
  • 学会使用循环控制语句(break/continue

🧩 核心内容

1. for 循环示例

# 遍历列表
fruits = ["苹果", "香蕉", "橙子"]
for fruit in fruits:
    print(fruit)
for_循环

2. while 循环示例

# 条件循环
count = 0
while count < 5:
    print("当前计数:", count)
    count += 1
while_循环

3. 循环控制技巧

  • break:立即终止循环
  • continue:跳过当前迭代,继续下一次循环
  • else:当循环正常结束时执行(未被break打断)

📚 扩展阅读

想深入了解循环进阶用法?可访问 课程/videos/week3/video5 查看更多内容!

💡 小贴士

循环是编程的基石,合理使用能大幅提高代码效率!🎯

循环_示意图