Recall & Review
beginner
What are the three main logical operators used in Python conditions?
The three main logical operators are and, or, and not. They help combine or invert conditions.
Click to reveal answer
beginner
How does the
and operator work in a condition?The
and operator returns True only if both conditions are true. If either is false, the whole condition is false.Click to reveal answer
beginner
Explain the behavior of the
or operator in conditions.The
or operator returns True if at least one of the conditions is true. It returns False only if all conditions are false.Click to reveal answer
beginner
What does the
not operator do in a condition?The
not operator reverses the result of a condition. If the condition is true, not makes it false, and vice versa.Click to reveal answer
beginner
Given the code: <br>
if age >= 18 and has_id:<br>What does this condition check?It checks if both conditions are true: the person is 18 or older and the person has an ID. Both must be true for the code inside the if to run.
Click to reveal answer
Which logical operator returns True only if both conditions are true?
✗ Incorrect
The
and operator returns True only if both conditions are true.What will the expression
not (5 > 3) evaluate to?✗ Incorrect
Since 5 > 3 is True,
not True is False.Which operator would you use to check if at least one condition is true?
✗ Incorrect
The
or operator returns True if at least one condition is true.What is the result of
True and False?✗ Incorrect
and requires both to be True, so True and False is False.If
condition = False, what does not condition evaluate to?✗ Incorrect
not reverses the value, so not False is True.Explain how the logical operators
and, or, and not work in Python conditions.Think about combining simple yes/no questions.
You got /3 concepts.
Write a simple example using
and and not in an if statement and explain what it checks.Use a real-life example like checking age and permission.
You got /2 concepts.