What does function mean?
A named block of code that does one job and can be called from anywhere in a program. It may take parameters and may return a value. Also called a subroutine or, when it returns nothing, a procedure.
In a lesson
The functions in the last lesson did the same thing every time. Real functions take information in and give an answer back, the way
forward(50)takes a speed anddistance()gives a number. This lesson is about both directions.
Learn it
- Taught in F4.2 Parameters and return values Functions and structured code, GCSE
Used in
- F1.1 What a program is
- F1.3 Calling functions
- F1.8 Data types and casting
- F1.9 Arithmetic operators
- F1.10 Project: ask and drive
- F3.1 String handling
- F3.4 Iterating over a list
- F3.7 Random numbers
- F4.1 Writing functions
- F4.3 Local and global variables
and 134 more lessons.
Do the lesson in the simulator