Edexcel 1CP2 6.2.1: Structural components of programs
The free BugBot lesson that teach this point, a robot to try it on, and the past-paper questions that test it.
What it covers
Until now every program has been a flat list: one line after another. Real programs have structure: some lines belong together as a group, and the group runs only sometimes, or runs many times. Python shows those groups with indentation, the spaces at the start of a line. This lesson is about that, before the rest of the module uses it for real.
- A block is a group of lines
- The colon and the indent go together
- How much to indent
- Where a block ends
- Blocks inside blocks
- Why Python does it this way
Or do it in the simulator, with tasks that mark themselves
Lessons that teach it
- F2.1 Blocks and indentation Decisions and loops
How Python groups lines: the colon and the indent.
Try it on a robot
The task from F2.1 Blocks and indentation, running here. Change the program and press Run.
The specification is Edexcel's own document; this page says which of our lessons teach point 6.2.1 and is not endorsed by the board.