← Years 7–8 Creating Digital Solutions

Python and, or, not

Logical operators that combine or flip True/False conditions. and needs both True, or needs at least one True, and not reverses True to False (or False to True).

Understanding Python and, or, not in Years 7–8 Creating Digital Solutions

What it does: not flips the value of raining. The code inside the if runs when raining is False. With and, both score > 50 and time < 10 must be True for the if block to run. and needs BOTH sides to be True. 13 > 12 is True and 13 < 15 is True, so the answer is True. score > 50 is False. With and, one False makes the whole condition False. or only needs at least ONE side to be True. is_raining is True, so the result is True. not reverses a Boolean value. not True becomes False. Each side of and must be a full condition. You need to write x again after and.

Common mistakes: Python does not use && for 'and'. Write the word and: ok = age >= 12 and has_pass. Python's logical operators must be lowercase. AND causes an error. It should be: a = True and False.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 50–125) and word search (Modules 3–125).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which result does this give? age = 13 and True: print(age > 12 and age < 15)
TrueFalse
Matches
if x > 5 or < 10:
↓
Each side of or needs a full condition. It should be: if x > 5 or x < 10:
Applying
Meanings
Term
and, or, not
Meaning
Logical operators that combine or flip True/False conditions. and needs both True, or needs at least one True, and not reverses True to False (or False to True).
Practice
age = 13
Testing
Gaps
if age > 12 age < 20:
Check Answer
Spots
3print("Checking entry")
4ok = age >= 12 && has_pass

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Coelacanth' badge — Living Fossil, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which result does this give? age = 13 and True: print(age > 12 and age < 15)
A. True ✓
B. False
and needs BOTH sides to be True. 13 > 12 is True and 13 < 15 is True, so the answer is True.
2. score = 40. What does print(score > 50 and score < 100) show?
A. True
B. False ✓
score > 50 is False. With and, one False makes the whole condition False.
3. is_raining = True, has_umbrella = False. What does print(is_raining or has_umbrella) show?
A. True ✓
B. False
or only needs at least ONE side to be True. is_raining is True, so the result is True.
4. Which sentence about or is correct?
A. or is True only when both sides are True
B. or is False only when both sides are False ✓
That describes and, not or. or needs just one True side, so it is False only when both are False.
5. What does print(not True) show?
A. False ✓
B. True
not reverses a Boolean value. not True becomes False.

Match the Pairs

age >= 12 and age <= 15 → True only when BOTH conditions are True, so age must be from 12 to 15
day == "Sat" or day == "Sun" → True when at least ONE condition is True, so it is a weekend day
not reverses a condition: True becomes False and False becomes True → if not raining:
and needs both conditions True before the code inside the if runs → if score > 50 and time < 10:
if x > 5 or < 10: → Each side of or needs a full condition. It should be: if x > 5 or x < 10:
if And(age > 12, age < 15): → and is a lowercase operator placed between two conditions, not a function. It should be: if age > 12 and age < 15:

Key Term

and, or, not
Logical operators that combine or flip True/False conditions. and needs both True, or needs at least one True, and not reverses True to False (or False to True).

Fill in the Blanks

1. if age > 12 and age < 20: print("Teenager")
Hint: Type the logical operator that needs both conditions to be True.
2. if day == "Sat" or day == "Sun": print("Weekend")
Hint: Type the logical operator that needs only one condition to be True.
3. raining = False if not raining: print("Play outside")
Hint: Type the logical operator that reverses False into True.
4. sunny = True warm = False print(sunny or warm)
Hint: Type the operator that gives True when at least one value is True.
5. if score > 50 and not cheated: print("Pass")
Hint: Type the operator that flips the cheated value, so the student must NOT have cheated.

Spot the Error

Question 1
A age = 14
B has_pass = True
C print("Checking entry")
D ok = age >= 12 && has_pass
E print(ok)
Line D — Python does not use && for 'and'. Write the word and: ok = age >= 12 and has_pass.
Question 2
A a = True AND False
B b = True or False
C print(a)
D print(b)
Line A — Python's logical operators must be lowercase. AND causes an error. It should be: a = True and False.
Question 3
A sunny = True
B warm = False
C if sunny warm:
D print("Go outside")
Line C — There is no operator between sunny and warm. Join the conditions with or: if sunny or warm:.
Question 4
A raining = False
B print("Checking weather")
C if !raining:
D print("Leave umbrella")
Line C — Python does not use ! for reversing a condition. Use the word not: if not raining:.
Question 5
A ready = True and
B print(ready)
C print(not ready)
Line A — and needs a True/False value on both sides. The right side is missing. It should be: ready = True and True.

Student with a class code? Join your class →