Lesson 02 · Python
Python Foundations: Functions & Control Flow
Define functions with parameters and return values, branch with if/elif/else, loop with for and while, and use defaults, docstrings, break and continue well.
Prerequisites: Python Foundations: Values, Variables & Types
Learning objectives
By the end of this lesson, you will be able to:
- Define functions with def, parameters and explicit returns
- Branch with if, elif and else using comparison and logical operators
- Loop with for over iterables and range()
- Control while loops with break and continue, and avoid infinite loops
- Write default parameter values and docstrings