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

Boolean operations in conditions

Practise 25 exam-style questions on Boolean operations in conditions 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.

  • 25 questions
  • 1–7 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 and b are Boolean variables. a is True and b is False.

Which one of the following expressions evaluates to True?

Choose your answer.

  • a AND b
  • NOT a
  • NOT (a OR b)
  • a AND (NOT b)

Model answer

a AND (NOT b)

Explanation

NOT b is True because b is False, and a is True, so a AND (NOT b) is True AND True, which is True. a AND b is False because b is False, NOT a is False, and a OR b is True, so NOT (a OR b) is False.

Mark scheme
  1. 1 mark

    a AND (NOT b)

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

Question 2

2 marks

x holds the value 7. The two conditions below contain the same comparisons but have their brackets in different places.

Condition 1: ((x > 5) OR (x < 10)) AND (x = 4)
Condition 2: (x > 5) OR ((x < 10) AND (x = 4))

State whether each condition evaluates to True or False.

Model answer

Condition 1: (True OR True) AND False = True AND False = False
Condition 2: True OR (True AND False) = True OR False = True

Explanation

With x = 7, x > 5 is True, x < 10 is True and x = 4 is False. In condition 1 the OR is worked out first (True), and then True AND False gives False. In condition 2 the AND is worked out first (False), and then True OR False gives True, which shows why brackets should always be used when AND and OR are mixed.

Mark scheme
  1. 1 mark

    Condition 1: False

    Both marks AO2 (apply). A. F / T. I. Case.

  2. 1 mark

    Condition 2: True

Question 3

3 marks

A nature quiz asks how many legs a spider has and gives the user up to three attempts.

attempts ← 0
REPEAT
  answer ← USERINPUT
  attempts ← attempts + 1
UNTIL (answer = 8) OR (attempts = 3)
IF answer = 8 THEN
  OUTPUT 'Correct'
ELSE
  OUTPUT 'The answer was 8'
ENDIF
OUTPUT attempts

State the outputs when the user enters 6 and then 8

State the outputs when the user enters 4, then 6, then 10

Model answer

6 then 8: Correct, then 2
4, 6, 10: The answer was 8, then 3

Explanation

REPEAT ... UNTIL stops as soon as its condition is True, and OR makes it True when either part is True. With 6 then 8, answer = 8 becomes True on the second attempt, so the loop stops with attempts = 2. With three wrong answers, attempts = 3 becomes True instead, so the loop stops and the ELSE message is output, followed by 3.

Mark scheme
  1. 1 mark

    6 then 8: Correct

    All marks AO2 (apply). I. Quotation marks. I. Case.

  2. 1 mark

    6 then 8: 2

  3. 1 mark

    4, 6, 10: The answer was 8 and then 3

    Both outputs are needed for the mark.

Question 4

4 marks

The algorithm below adds up to four numbers entered by the user, stopping early if 0 is entered.

total ← 0
count ← 0
num ← USERINPUT
WHILE (num ≠ 0) AND (count < 4)
  total ← total + num
  count ← count + 1
  num ← USERINPUT
ENDWHILE
OUTPUT total

The user enters 5, 8, 3, 6 and 9, in that order. Complete the trace table in the figure for the algorithm. The first row has been completed for you. You may not need to use all the rows in the table.

Give the values in each column, in order.

Trace table with four columns: total, count, num and OUTPUT. Row 1: total = 0, count = 0, num = 5; OUTPUT blank. Rows 2 to 8 are empty, for the student to complete.

Model answer

total: 0, 5, 13, 16, 22
count: 0, 1, 2, 3, 4
num: 5, 8, 3, 6, 9
OUTPUT: 22

Explanation

The loop continues only while both conditions are True. After four numbers count is 4, so count < 4 is False and the loop stops, even though 9 has been read and is not 0. AND stops the loop as soon as either condition becomes False, so 9 is never added and 22 is output; 31 is the common wrong answer.

Mark scheme
  1. 1 mark

    total column: 5, 13, 16, 22 (after the given 0)

    All marks AO2 (apply). I. Different rows used as long as the order within each column is clear. I. Duplicate values on consecutive rows within a column.

  2. 1 mark

    count column: 1, 2, 3, 4 (after the given 0)

  3. 1 mark

    num column: 8, 3, 6, 9 (after the given 5)

  4. 1 mark

    OUTPUT: 22, output once only, after the loop has finished

    R. 31 (9 is read but is not added).

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.