So far, every program we’ve seen runs top to bottom, one line at a time. Control flow is how we change that — making decisions with if, repeating actions with loops, and picking between options with pattern matching.
What’s in this section
if,elif,else— making decisionsforloops — repeat an action for each item in a collectionwhileloops — repeat as long as a condition is truebreak,continue,pass— control the flow inside loopsrange()and iterables — what loops actually loop over- Pattern matching with
match/case— modern Python’s switch statement
After this section, you’ll be able to write programs that respond to different inputs, repeat work, and process collections of data. That’s most of what real programs do.