Locked lesson.
About this lesson
What are the logical operators AND/OR/NOT and how do we use them?
Exercise files
Download this lesson’s related exercise files.
Multiple Conditionals.docx60.4 KB Multiple Conditionals - Solution.docx
59.1 KB
Quick reference
Multiple Conditionals
It's possible to reference multiple conditional statements inside an if statement.
When to use
Use this whenver you need to make more than one type of comparison in an If statement.
Instructions
You can make multiple comparisons inside an IF statement using "and" & "or":
if (5 > 3) and (5 == 5):
print("Hi there")
if (5 > 3) or (5 == 5):
print("Hi there")
For "and" both conditions must be true for the thing to evaluate to true.
For "or" only one of the conditions must be true for the thing to evaluate to true.
Hints & tips
- Use and/or to test multiple comparisons
Lesson notes are only available for subscribers.