Skip to main content

Chapter 17: Control Flow and Loops

Welcome to Chapter 17! In this chapter, you'll learn how to make your Python programs intelligent and efficient by teaching them to make decisions and repeat actions automatically.

What You'll Learn

By the end of this chapter, you will be able to:

  • Make decisions in code using if, elif, and else statements
  • Use pattern matching with Python's modern match-case syntax
  • Automate repetition using for and while loops
  • Control loop behavior with break, continue, and loop-else patterns
  • Combine decisions and loops to solve complex problems
  • Describe your intent clearly so AI can help you write correct control flow logic
  • Validate your logic by testing edge cases and understanding execution flow