Beginner · Lesson 7 of 12

Your first function

A function packages a useful operation under a name. Parameters supply input, and a return value carries the result back to the caller. Keep printing separate from calculation so you can reuse and test the function.

Try it for yourself

Run the example, then change one thing and see what happens.

13px
main.pyYour ideas, in code.
Loading your editor…
Run your code to see the output here.
Ready to buildUTF-84 lines

Expected output

14

Make it your own

Write a function that doubles its input.

A quick check

Which habit helps when learning your first function?

PreviousNext lesson