Back to Python course
PyReusable CodeBeginnerLive Python12 min
Functions
Group reusable code under a name with parameters and return values.
Explanation cell
Functions group reusable code under a name. They can receive input through parameters and send a result back using return.
defparametersreturn values
Quick tip
Use return when a function should send a value back to the caller.
Common mistake
Calling a function before it is defined can make examples harder to follow.
Code cell
Starter code · Ctrl+Enter runs · Ctrl+Shift+Enter tests
Python runtime loads on first run
Output cell
Run your code to see output.
Run your code to see output.
Test cell
Tests run against the actual Python output.
Run tests to check your code against the lesson goals.
Practice cell
Try this
Create an add function that returns the sum of two numbers.
Expected output
Hello Ada