Skip to main content
EnglandComputer ScienceSyllabus dot point

What are the structural components of a program, and how do you use sequence, selection, repetition and iteration in Python?

Identify the structural components of programs (constants, variables, initialisation, assignment, sequence, selection, repetition, iteration, data structures, subprograms, parameters, input/output) and write programs that use sequencing, selection, repetition (count-controlled, condition-controlled) and iteration with single entry and exit points.

A focused answer to Edexcel GCSE Computer Science 6.2, covering the structural components of programs and writing Python programs that use sequence, selection, count-controlled and condition-controlled repetition, and iteration.

Generated by Claude Opus 4.89 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. The structural components of a program
  3. Sequence
  4. Selection
  5. Repetition and iteration
  6. Single entry and exit points
  7. Try this

What this dot point is asking

Edexcel wants you to identify the structural components of a program and to write Python programs that use sequence, selection, repetition (count-controlled and condition-controlled) and iteration, with single entry and exit points from code blocks.

The structural components of a program

These are the named parts a question may ask you to point out in a piece of code. For example, in a program, the line total = 0 is initialisation (and assignment) of a variable; an if is selection; a for is repetition; input() and print() are input/output; and a defined function is a subprogram. Knowing the vocabulary lets you answer "identify the selection statement" or "name the component on line 3".

Sequence

name = input("Name: ")
print("Hello " + name)

These two lines run in sequence: read the name, then greet.

Selection

if mark >= 40:
    print("pass")
else:
    print("fail")

For several cases, chain with elif (as in the positive/negative/zero example), which is cleaner and more efficient than separate if statements because once a branch matches the rest are skipped.

Repetition and iteration

# Count-controlled: known number of repeats
for i in range(1, 6):
    print(i)

# Condition-controlled: repeat until the user types "quit"
command = ""
while command != "quit":
    command = input("Command: ")

# Iteration over every item in a list
for score in scores:
    print(score)

The choice is the same logic as in algorithms: a for/range loop when the count is known, a while loop when it depends on a condition, and a for ... in loop to process each element of a structure.

Single entry and exit points

Writing structured code, where each loop and subprogram has one way in and one way out, keeps the flow predictable. It is part of structured programming and is why GCSE algorithms avoid unstructured jumps: a reader can follow the logic top to bottom without tracking jumps into the middle of a block.

Try this

Q1. State which Python construct repeats a known number of times. [1 mark]

  • Cue. A for loop (over a range), which is count-controlled repetition.

Q2. Write a Python if statement that prints "big" when a variable n is greater than 100. [2 marks]

  • Cue. if n > 100: then on the next indented line print("big").

Exam-style practice questions

Practice questions written in the style of Pearson Edexcel exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

Edexcel 20225 marksWrite a Python program that asks the user for a whole number and prints whether it is positive, negative or zero.
Show worked answer →

A correct solution reads the input, converts it to an integer, then uses selection with elif.

number = int(input("Enter a whole number: "))
if number > 0:
    print("positive")
elif number < 0:
    print("negative")
else:
    print("zero")

Markers reward reading the input and converting it with int(), correct use of if/elif/else covering all three cases (positive, negative, zero), correct comparisons, and matching output. Using a single chain (if/elif/else) is cleaner than three separate ifs.

Edexcel 20215 marksWrite a Python program that uses a count-controlled loop to print the squares of the numbers 1 to 5 (that is 1, 4, 9, 16, 25).
Show worked answer →

Use a for loop over range(1, 6), printing each number multiplied by itself (or to the power 2).

for i in range(1, 6):
    print(i * i)

This is count-controlled (definite) iteration because the number of repetitions (5) is known. The output is 1, 4, 9, 16, 25.

Markers reward a correct loop range that gives 1 to 5, computing the square (i * i or i ** 2), printing inside the loop, and producing the five correct values. Using range(1, 5) would be an off-by-one error.

Related dot points

Sources & how we know this