A function is a reusable block of code that you can call later to perfume a task. It is used to reduce repetition and centralises change so you can fix the logic once instead of multiple times.
To create a function in Python, you use the def keyword, followed by a name, parentheses, and a colon.

Parameter is the names in the function definition that acts as a placeholder.
Argument is the actual values that you pass when invoking the function.
Return values.
We have something called the return value which calculates what you want and hands back the results.

Multiple Parameters
Functions can use multiple parameters that's separated by commas and the arguments are matched in order.

Functions calling other Functions
You can combine functions to create something like a building block.

Top comments (0)