National 5 Computing Science
round, random and length: writing the whole call
National 5 Computing Science: Software design and development
National 5 uses three predefined functions: round, random and length. Most candidates can name them. The examiners' reports for 2023 and 2024 say marks are lost when the call is not written in full.
round
SET average TO round(average, 1)
Two parameters, in this order: the value to round, then the number of decimal places. If average holds 8.4667, it now holds 8.5. Using round is usually 2 marks: one for the function with its brackets, one for both parameters in the right order.
random
SET dice TO random(1, 6)
The two parameters are the lowest and highest values, and both ends can come up: this line gives 1, 2, 3, 4, 5 or 6. Using random can be worth 3 marks: the function, the right range, and storing the result in the variable the question names.
A common use is to pick a random item from an array. Array indexes start at 0, so for an array of 7 days the call is random(0, 6), not random(1, 7).
length
SET letters TO length(password)
length gives the number of characters in a string, or the number of items in an array. A "length check" is something different: a kind of validation. Writing "length check" when asked for the function does not gain the mark.
- The whole call: name, brackets and every parameter.
- The result stored or used:
SET dice TO random(1, 6), not justrandom(1, 6)on its own. - Python names are fine if you write in Python:
round(average, 1),random.randint(1, 6)andlen(password).
Try two exam-style questions
Choose an answer, say how sure you are, then press Check. Every wrong answer tells you why it is wrong.

The full course covers every topic like this. Every topic in National 5 Computing Science has a short note, a simulation to try and a practice quiz with feedback on every answer, plus coding lessons, a full mock exam and a progress report for parents.
More guides
- Input validation: how to get all 4 marks
- Running total within a loop
- Choosing the most suitable data type
- Evaluating a program: answers that gain the mark
- Concatenation: joining strings for the mark
- Iterative development: describing going back
- Testing: test data and test tables
- All the free revision guides
This site is independent: it is not connected to the SQA or Qualifications Scotland. Points from the examiners' course reports are given in our own words.