Level:
Correct: 0
Incorrect: 0
Marks: 0/0
Exam Practice
Course:
Topics:
AQA GCSE Computer Science (Paper 1) Smart practice A mixed round aimed at your weak spots
Unit 1
3.1 Fundamentals of algorithms
Unit 2
3.2 Programming
Data types
Data types
Arithmetic operations in a programming language
Arithmetic operations, DIV and MOD
Relational operations in a programming language
Relational operations
Boolean operations in a programming language
Boolean operations in conditions
Data structures
Arrays and records
Input/output
Input and output
String handling operations in a programming language
String handling
Random number generation in a programming language
Random number generation
Structured programming and subroutines (procedures and functions)
Subroutines and structured programming
Avg
score:
–
Topics
done:
0/15

Relational operations

Practise 30 exam-style questions on Relational operations for AQA GCSE Computer Science (Paper 1). Write your answer as you would in the exam and get it marked in seconds against the mark scheme, point by point, with the Study Helper on hand if you get stuck.

  • 30 questions
  • 1–6 marks each
  • Instant marking
  • No sign-up needed
20 questions, marked as you go

Sample questions with model answers

Here are 4 of the questions in this topic, each with a model answer, an explanation of why it earns the marks and the mark scheme an examiner would use.

Question 1

1 mark

Ages are stored as whole numbers.

Which one of the following conditions is True for exactly the same ages as the condition age ≥ 18?

Choose your answer.

  • age > 17
  • age > 18
  • age ≤ 17
  • age < 18

Model answer

age > 17

Explanation

For whole numbers, 'greater than 17' starts at 18, so age > 17 is True for 18, 19, 20 and so on, exactly like age ≥ 18. age > 18 leaves out 18 itself, while age ≤ 17 and age < 18 are True for the ages under 18, which is the opposite.

Mark scheme
  1. 1 mark

    age > 17

    If more than one option is given, 0 marks. Mark is for AO2 (apply).

Question 2

2 marks

A fish tank monitor outputs a warning if the water is too cold or too hot. Temperatures are whole numbers of °C. Below 22 is too cold and above 28 is too hot; 22 and 28 themselves are OK.

Two conditions have been replaced by the labels A and B.

temp ← USERINPUT
IF A THEN
  OUTPUT 'Too cold'
ELSE IF B THEN
  OUTPUT 'Too hot'
ELSE
  OUTPUT 'OK'
ENDIF

State the conditions that should replace the labels A and B.

Model answer

A: temp < 22
B: temp > 28

Explanation

'Below 22' means 22 itself is not included, so the condition is temp < 22; 'above 28' similarly gives temp > 28. Testing the boundaries shows the difference: with temp ≤ 22 a reading of 22 would wrongly be too cold. For whole numbers, temp ≤ 21 and temp ≥ 29 are equivalent.

Mark scheme
  1. 1 mark

    A: temp < 22

    Both marks AO3 (program). A. temp ≤ 21. A. Equivalent code in C#, Python or VB.NET. I. Case. R. temp ≤ 22 (22 would be too cold).

  2. 1 mark

    B: temp > 28

    A. temp ≥ 29. R. temp ≥ 28 (28 would be too hot).

Question 3

2 marks

The pseudo-code below uses the not equal to operator.

01count ← 0
02WHILE count ≠ 10
03  count ← count + 3
04ENDWHILE
05OUTPUT count

Describe what happens when the pseudo-code is run.

Rewrite line 2 so that the loop stops as soon as count reaches or passes 10

Model answer

count goes 3, 6, 9, 12, 15 ... so it is never exactly 10. The condition count ≠ 10 is always True, so the loop never ends (an infinite loop) and nothing is output.
Corrected line 2: WHILE count < 10

Explanation

≠ only stops the loop if count is exactly 10, but adding 3 each time jumps from 9 straight to 12, so the condition is always True and the loop runs forever. Using < 10 stops the loop at the first value that is 10 or more, so the corrected code outputs 12. When a counter goes up in steps, < or ≤ is safer than ≠.

Mark scheme
  1. 1 mark

    count takes the values 3, 6, 9, 12 ... and is never equal to 10, so the loop never stops // it is an infinite loop

    AO2 (apply). NE. 'it crashes' / 'there is an error'.

  2. 1 mark

    WHILE count < 10

    AO3 (refine). A. WHILE count ≤ 9. A. WHILE NOT (count ≥ 10). A. Equivalent code in C#, Python or VB.NET. I. Case.

Question 4

5 marks

Write a program that:
- gets the user to enter two whole numbers
- outputs the larger of the two numbers
- outputs Equal instead if the two numbers are the same.

For example, if the user enters 8 and then 3, the program outputs 8; if the user enters 5 and then 5, it outputs Equal.

You should use meaningful variable names in your answer.

You should write your answer in C#, Python or VB.NET.

Model answer

first = int(input())
second = int(input())
if first > second:
    print(first)
elif second > first:
    print(second)
else:
    print("Equal")

Explanation

The program has three possible outcomes, so an if ... elif ... else structure fits: one test for first > second, one for second > first, and the else catches the equal case. Using >= in the first test would output the number instead of Equal when the two are the same. Testing with 8 and 3, then 3 and 8, then 5 and 5 checks every path.

Mark scheme
  1. 1 mark

    Mark A for using selection to compare the two numbers

    Program Design (1 mark for AO3 design). Design marks are for selecting appropriate techniques, so they are credited whether or not the syntax is correct and whether or not the solution works.

  2. 1 mark

    Mark B for getting two values from the user and storing them as integers in two variables

    Program Logic (4 marks for AO3 program).

  3. 1 mark

    Mark C for a correct relational test to decide which number is larger, e.g. first > second

    A. second < first. A. Either test written the other way round if the outputs match it.

  4. 1 mark

    Mark D for outputting the larger number correctly, whichever of the two numbers is larger

  5. 1 mark

    Mark E for outputting Equal when the two numbers are the same, and only then (with no number also output)

    R. If >= or <= is used so that a number is output instead of Equal for equal values.
    Maximum 4 marks if any errors in code.
    I. Case
    I. Indentation
    I. Messages or no messages with input statements
    I. Gaps/spaces throughout the code, except where to do so would explicitly alter the logic of the code in a way that makes it incorrect.
    Minor syntax errors that do not affect the logic are not penalised, e.g. missing colons or semicolons, = or == in a condition, misspelt keywords whose meaning is clear.
    Note to examiners: the C# and VB.NET examples include variable declarations so that they run; as in AQA's marking guidance, a missing declaration that would make the code correct is marked as if it were present, and any correct declaration is accepted.
    Python Example 1 (fully correct):
    first = int(input())
    second = int(input())
    if first > second:
    print(first)
    elif second > first:
    print(second)
    else:
    print("Equal")
    C# Example 1 (fully correct):
    int first = Convert.ToInt32(Console.ReadLine());
    int second = Convert.ToInt32(Console.ReadLine());
    if (first > second)
    {
    Console.WriteLine(first);
    }
    else if (second > first)
    {
    Console.WriteLine(second);
    }
    else
    {
    Console.WriteLine("Equal");
    }
    A. Write in place of WriteLine. I. Missing Console.
    VB.NET Example 1 (fully correct):
    Dim first As Integer = Console.ReadLine()
    Dim second As Integer = Console.ReadLine()
    If first > second Then
    Console.WriteLine(first)
    ElseIf second > first Then
    Console.WriteLine(second)
    Else
    Console.WriteLine("Equal")
    End If
    A. Write in place of WriteLine. I. Missing Console.

Ready to try the rest? Every answer you write is marked against the mark scheme, so you can see exactly where the marks are.

Study Helper Hints first, answers after you try

Stuck on this one? Ask for a hint and I’ll point you in the right direction, without giving the answer away. Once you’ve checked your answer, I’ll show you how the marks are awarded.