Expressions that evaluate to True or False: the relational operators on numbers, == for equal values against is for the same object, None, in for membership, and which values count as true in their own right.
No account needed to read a lesson · 30-day money-back guarantee
See the full learning path8
lessons
45
practice questions
36
prerequisite lessons
1 of the 8 lessons here is free to preview - the whole explanation and worked example, with no account and no email.
The editor you get
A still of the editor, not a live one
Python Editor
Editor Output
Output:
True False
You write and run Python in the browser - nothing to install, no setup. Questions are marked on the values your code produces. The snippet here is an example of the kind of code you write.
The 8 lessons in this unit. Expand any one to see what it covers. Each unlocks when its own prerequisites are passed.
01
Variables and object references
8 questions
Understand that variables in Python act as labels referencing objects in memory, not as containers of data, and see how functions like id() reveal whether different variables point to the same object.
Covers
Variables hold references to objects
Using id() to inspect object references and memory location
02
Comparing numbers with relational operators
8 questions
Learn to use Python's relational operators to compare numeric values and interpret the resulting boolean outcomes.
Covers
Types of relational operators
Comparing numbers with relational operators
03
Identity and value equality of objects
8 questions
Learn the difference between object value equality using == or != to compare stored values and object identity equality using is or is not to determine whether two variables refer to the same object in memory.
Covers
Object value equality
Object identity equality
04
None
4 questions
Understand the meaning of None in Python, its singleton nature, its type, how to compare objects to None using is, and its behaviour in boolean contexts.
Covers
None
05
Membership testing
4 questions
Learn how to use the in and not in operators in Python to check whether a value is present in a list, tuple, set, string or as a key in a dictionary, based on value equality.
Covers
Membership testing
06
Creating booleans from expressions
4 questions
Learn how to construct complex boolean expressions in Python by chaining multiple comparisons and mixing logical and membership operators to evaluate compound conditions clearly and concisely.
Covers
Chaining and mixing comparisons
07
Truthiness and falsiness
4 questions
Learn how Python determines the truth value of objects in boolean contexts, distinguishing between "truthy" and "falsy" values such as zero, empty collections, and None.
Covers
Every object has a truth value
08
Activity: the vault of secrets
5 questions
Work through a sequence of Python programming challenges that progressively unlock levels of a secret vault, requiring careful validation of both logic and code output at each stage.
Covers
Inspect the keys
Verify the owner
Valid codes
Approved codes
Opening the vault
This unit is part of our Python Done Right learning path, which contains 100 lessons. Every one of them is drawn below.
The diagnostic test lets you skip any lesson you already know, including the ones in this unit.
Hover any dot to name its lesson.
8 lessons in this unit
36 prerequisite lessons across the unit, counting every step back to the start
56 other lessons in the learning path - after this unit, or alongside it
Builds on: Basic data types, Conditional logic, Lists, Python basics, Sets
Leads to: Assorted extras, Built-in functions, Conditional logic, Dictionaries, Sequences, Sets, Tuples, User-defined functions
One subscription covers every learning path, and you can test out of anything you already know.
One subscription covers every learning path · 30-day money-back guarantee
More in Conditional logic & comparisons: Conditional logic