Programming fundamentals›Functions
Tutorial 4 of 13 · Programming fundamentals · Values and flow · BeginnerFunctions
Give a block of steps a name, so you can use it anywhere by that name.
6 lessons, the last is a challenge · about 1 h · Python and Java
Before you startYou finished "Repeating": you can use values, variables, arithmetic, print, conditions and loops.
What you’ll be able to do
- 1Write a function (def in Python, a static method in Java), call it by name, and say which lines run and when.
- 2Give a function inputs through its parameters, call it with different arguments, and say what each call prints.
- 3Hand a result back with return, use that result in the calling line, and tell return from print.
- 4Read a trace of functions calling functions and say which frames are open at any moment.
- 5Say where a variable lives: a box made inside a function belongs to that call and is gone when the function returns.
Lessons
Next in this path
Next: 5 · Lists · 5 lessons · 1 h
Keep many values in one place, in order, and go through them one by one.
Playground
Try the same model with your own values. No checks, nothing recorded.
Open the playground