Fun computer science · Classes 6 to 10
Coding basics: variables, decisions and lists
Programs are just careful instructions. Read a few lines the way the computer does, guess what it prints, then run it and see.
1. Variables are named boxes
Each line changes what is in the boxes. Predict the final x, then set the numbers and run the program.
2. Making a decision
A program can choose. Set the pass mark and the student’s marks, and see which branch runs.
3. Lists and indexes
A list keeps many values in a row. The first item is at index 0, not 1.
Remember in one minute
- A variable is a named box. x = x + 1 reads the old x, adds 1 and stores the new value back.
- if / else chooses one of two blocks. = stores a value; == compares. >= means “greater than or equal”.
- Lists start at index 0. len = how many, sum = total, max/min = biggest/smallest.
- // gives the whole-number quotient and % the remainder: 17 // 5 = 3 and 17 % 5 = 2.
Practice now: 3 levels, worked answers, progress tracker →
This is a practice aid made by BodhiScore, not a textbook or an official board resource. Your school’s textbook decides the exact syllabus and the way answers are written. Nothing on this page is saved or sent anywhere. This is a practice aid, not a substitute for your school textbook. These are standard computing facts; where a value depends on a convention the question says which one is used.