Skip to main content
ScotlandComputer ScienceSyllabus dot point

What building blocks do we combine in a high-level language to make a program work?

Computational constructs: assignment, arithmetic, comparison and logical operators, concatenation, predefined functions, and the control structures of selection and iteration (fixed and conditional).

An SQA National 5 Computing Science answer on computational constructs, covering assignment, arithmetic, comparison and logical operators, string concatenation, predefined functions, and the control structures of selection (IF) and iteration (fixed and conditional loops) used to build programs in a high-level language.

Generated by Claude Opus 4.811 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 key area is asking
  2. Assignment and operators
  3. Concatenation and predefined functions
  4. Selection: choosing a path
  5. Iteration: repeating steps
  6. Putting constructs together
  7. How this key area is examined
  8. For the official course specification

What this key area is asking

The SQA wants you to read and write programs in a high-level language using the core computational constructs: assignment, the arithmetic, comparison and logical operators, string concatenation, predefined functions, and the two control structures of selection and iteration.

Assignment and operators

Programs combine values using three families of operator:

  • Arithmetic operators do calculations: add +, subtract -, multiply *, divide /, raise to a power (^ or **), and modulo (the remainder after division, often MOD or %). Modulo is useful for tests like "is this number even?" (number MOD 2 = 0).
  • Comparison operators compare two values and give a Boolean result: equal to =, less than <, greater than >, less than or equal <=, greater than or equal >=, and not equal to <>. They are used in conditions.
  • Logical operators combine Boolean values: AND (true only if both sides are true), OR (true if either side is true), and NOT (reverses true and false). They build more complex conditions, such as age >= 13 AND age <= 19.

Concatenation and predefined functions

Concatenation is how programs build messages from fixed text and variable values. Predefined functions cover common jobs: a random-number function for games, a length function to count characters, or a rounding function to control decimal places in output.

Selection: choosing a path

Selection lets a program behave differently in different situations: charge a child a lower price, display "Pass" or "Fail", or warn the user that input was invalid. The condition is built from comparison and logical operators.

Iteration: repeating steps

Iteration (looping) repeats statements so you do not have to write them many times. National 5 distinguishes two kinds.

Choosing the right loop is itself examined: a fixed loop when the count is known (process every pupil in a class of 30), a conditional loop when it depends on what happens (keep asking for a password until it is correct).

Putting constructs together

Real programs combine all of these: a loop (iteration) that contains an IF (selection) whose condition uses comparison and logical operators, building output by concatenation and using a predefined function for a calculation. Reading code in the exam means tracing it construct by construct; writing code means choosing the right construct for each part of the task.

How this key area is examined

Questions ask you to read code and state its output, or write code in a high-level language you have studied to meet a description. Expect to choose between a fixed and a conditional loop, build a condition from comparison and logical operators, use selection for different cases, and concatenate strings for output. Syntax must match the language you quote, but the marks centre on choosing the right construct for each part of the task.

For the official course specification

The SQA publishes the full National 5 Computing Science course specification, specimen question papers and coursework tasks at sqa.org.uk. Always revise from the current specification and SQA past papers, because question style and terminology are board-specific.

Exam-style practice questions

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

SQA N5 style4 marksUsing a high-level language you have studied, write code that displays the numbers from 1 to 10, each on a new line.
Show worked answer →

Four marks for a correct fixed loop that runs the right number of times and outputs each value.

Example (Python):

for number in range(1, 11):
print(number)

Markers reward a fixed (count-controlled) loop, the correct range so it runs ten times (1 to 10 inclusive), outputting the loop variable each pass, and correct syntax for the language quoted. The key idea is choosing a fixed loop because the number of repetitions is known in advance.

SQA N5 style3 marksA leisure centre charges 5 pounds entry, but children under 16 pay 3 pounds. Write code that reads an age and displays the correct charge.
Show worked answer →

Three marks for the input, the correct condition, and the two outcomes.

Example (Python):

age = int(input("Enter age: "))
if age < 16:
print("Charge is 3 pounds")
else:
print("Charge is 5 pounds")

Markers reward reading the age as a number, a correct comparison (age < 16), and selection that outputs 3 pounds for under-16s and 5 pounds otherwise. This tests selection (IF/ELSE) with a comparison operator.

Related dot points

Sources & how we know this