WeCodeAcademy

Functions

Define a function with def.

Examplepython
Open in editor »
Quick check

Which keyword defines a function?

Your turn: write the code

Define a function square(n) that returns n * n, then print square(7).

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.