PyPython · Lesson 4 of 14
Functions
Functions are reusable blocks of code. Write once, call many times. This is the foundation of not hating yourself when you have to change something.
Define functions with the def keyword. Parameters can have default values, and Python supports both positional and keyword arguments when calling functions.
Lambda functions are anonymous single-expression functions, useful for short operations passed to higher-order functions like sorted(), map(), and filter().