A-level Computer Science revision · Programming

Boolean conditions

The idea

A Boolean condition evaluates to True or False. Conditions combine comparison operators (==, ≠, <, >, ≤, ≥) with AND, OR and NOT. They control selection (if statements) and iteration (while loops).

  1. Work out each comparison.
  2. Apply NOT first, then AND, then OR.
  3. Check boundary values carefully.

Watch out In OCR pseudocode, == tests equality; = assigns a value.

See it worked

Worked example

Evaluate (5 > 3) AND NOT (2 == 2).

  1. 5 > 3 is True.
  2. 2 == 2 is True, so NOT gives False.
  3. True AND False is False.

Answer False

Your turn

Question 11 mark

x = 7. What is (x > 5) OR (x < 2)?

Choose one
Question 21 mark

Which condition is True when age is 16 or 17 only?

Choose one
Question 32 marks

Write a Boolean condition that is True when a mark is outside the range 0 to 100.

Write your answer, then see a model answer
  1. Use OR for 'outside'.
  2. Check both boundaries.

Answer mark < 0 OR mark > 100

A-level Computer Science Pro, OCR H446

A-level Computer Science Pro

£119 once

Price rises to £199 on 1 January. Save £80 by joining before then.

At least 12 months of access

By paying you agree to our Terms and get access straight away, which ends your 14-day cancellation right.

No VAT is charged.

Independent practice for OCR A-level Computer Science (H446), not endorsed by OCR.

Privacy · Terms