So far, we've seen functions that perform actions (like printing), but functions can also give back a value to the code that called them. This is done using the return keyword.
Think of a function like a calculator: you give it numbers (parameters), it does calculations, and then it returns the result to you.
↗️
Loading editor...
↶
↷
In this example:
1.
The function calculates the total power
2.
return sends that value back to where the function was called
3.
We store the returned value in the codemon_power variable
4.
We can then use that value however we want
Function Execution Stops at return
When Python encounters a return statement, it immediately exits the function. Any code written after return will not be executed!