Level:
Correct: 0
Incorrect: 0
Marks: 0/0
Exam Practice
Course:
Topics:
OCR GCSE Computer Science (Paper 2) Smart practice A mixed round aimed at your weak spots
Unit 1
Algorithms
Unit 2
Programming fundamentals
Unit 3
Producing robust programs
Unit 4
Boolean logic
Unit 5
Programming languages and IDEs
Unit 6
Practical programming (Section B)
Avg
score:
–
Topics
done:
0/31

Arithmetic, comparison and Boolean operators

Practise 30 exam-style questions on Arithmetic, comparison and Boolean operators for OCR GCSE Computer Science (Paper 2). 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

A program works out how many different values can be represented using n bits, using this statement.

combinations = 2 ^ n

State the value of combinations when n is 6.

Model answer

64

2 ^ 6 = 2 × 2 × 2 × 2 × 2 × 2 = 64

Explanation

2 ^ 6 means 2 multiplied by itself 6 times: 2, 4, 8, 16, 32, 64. A common mistake is to multiply 2 × 6 = 12, or to work out 6 ^ 2 = 36 by swapping the numbers. The base comes first and the power second.

Mark scheme
  1. 1 mark

    64

    Do not accept 12 (2 × 6) or 36 (6 ^ 2).

Question 2

2 marks

A board game has 40 squares numbered 0 to 39. After square 39, counters carry on from square 0. A program updates a player's position after each roll using this statement.

position = (position + roll) MOD 40

State the new value of position when position is 37 and roll is 6, and explain why MOD 40 is used.

Model answer

position = (37 + 6) MOD 40 = 43 MOD 40 = 3

MOD 40 gives the remainder after dividing by 40, so any total of 40 or more wraps back round to the start of the board and position always stays between 0 and 39.

Explanation

37 + 6 = 43 would be off the end of the board. 43 MOD 40 = 3 (40 goes into 43 once with 3 left over), which is exactly where the counter lands after passing square 39 and carrying on from 0. MOD is often used like this to make values wrap around, such as hours on a clock or positions on a circular board.

Mark scheme
  1. 1 mark

    3

    (37 + 6) MOD 40 = 43 MOD 40 = 3. Do not accept 43 or 1 (43 DIV 40).

  2. 1 mark

    MOD 40 makes the position wrap around (go back to the start) after square 39 / keeps the position in the range 0 to 39

    Accept 'so the position never goes past 39' or 'so the counter goes round the board again'.

Question 3

3 marks

A bus company charges a reduced fare to passengers who are under 16 or who are 60 and over. A passenger's age, as a whole number of years, is stored in the variable age.

Write an if statement, using OCR Exam Reference Language or a high-level programming language, that outputs "Reduced fare" for these passengers and "Full fare" for everyone else.

Model answer

if (age < 16) OR (age >= 60) then
    print("Reduced fare")
else
    print("Full fare")
endif

Explanation

A passenger qualifies if either condition is True, so the conditions are joined with OR. 'Under 16' is age < 16 (16 itself pays full fare) and '60 and over' is age >= 60 (60 itself is reduced). Using AND is a common error: nobody can be under 16 and over 60 at once, so the condition would never be True.

Mark scheme
  1. 1 mark

    checks age < 16

    Answers must be in OCR Exam Reference Language or a high-level programming language (e.g. Python); pseudocode, natural English or bullet points score 0. Ignore minor syntax errors. Accept age <= 15 (age is a whole number). Do not accept age <= 16.

  2. 1 mark

    checks age >= 60

    Accept age > 59. Do not accept age > 60.

  3. 1 mark

    the two conditions are joined with OR in a selection statement that outputs "Reduced fare" when True and "Full fare" otherwise (else)

    Do not accept AND (no age is both under 16 and 60 or over). Accept an if ... elseif ... else structure that gives the correct output for every age instead of OR. Ignore case and minor differences in the output text.

Question 4

4 marks

The program below should calculate the average of three marks and output "Pass" if the average is 50 or more. It contains two errors.

01mark1 = int(input("Enter mark 1"))
02mark2 = int(input("Enter mark 2"))
03mark3 = int(input("Enter mark 3"))
04average = mark1 + mark2 + mark3 / 3
05if average => 50 then
06    print("Pass")
07endif

Identify the line number of each error and write a corrected version of each of these lines.

Model answer

Line 04: average = (mark1 + mark2 + mark3) / 3
Line 05: if average >= 50 then

Explanation

Division is done before addition, so line 04 only divides mark3 by 3: with marks 60, 30 and 45 it gives 60 + 30 + 15 = 105 instead of the true average 45 - a logic error. Brackets make the addition happen first. In line 05, => is not a valid operator (a syntax error); 'greater than or equal to' is written >=.

Mark scheme
  1. 1 mark

    line 04 (is an error)

    Accept an explanation such as 'only mark3 is divided by 3' identifying line 4.

  2. 1 mark

    average = (mark1 + mark2 + mark3) / 3

    The brackets must surround all three marks. Do not accept DIV 3, which discards the fractional part of the average.

  3. 1 mark

    line 05 (is an error)

    Accept an explanation such as '=> is not a valid operator' identifying line 5.

  4. 1 mark

    if average >= 50 then

    Accept NOT (average < 50). Do not accept average > 50.

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.