Grade 9 · Media & Informatics
Use the ideas of variables and functions to structure a simple program.
A variable is a named store for a value that your program can read and change. Think of it as a labelled box: you might have a variable called score holding the number 0, and later set score to 10. The name stays the same while the value inside can change as the program runs.
A function is a named set of steps you can reuse. Instead of writing the same instructions again and again, you define them once, give them a name, and then 'call' that name whenever you need them. Many functions take an input and give back a result — for example, a function that takes a number and returns its double.
Together these are the building blocks of real programs. Variables hold the information the program is working with; functions organise the actions into reusable, well-named pieces. This keeps programs shorter, easier to read and easier to fix.
Have a go right here. Nothing is saved and you can retry as much as you like. Create a free account when you want to save your progress and get Archie, your tutor.
Create a free account to save your progress, track mastery and ask Archie, your tutor, for a hand.
Already with us? Open this lesson in learncoach.ch for mastery tracking and Archie, your tutor.