0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
No active XP Potion
Accept a Quest
Login to submit answers
You're probably familiar with the logical operators and
and or
.
Logical operators deal with boolean values, True
and False
.
The logical and
operator requires that both inputs are True
to return True
. The logical or
operator only requires that at least one input is True
to return True
.
For example:
True and True == True
True and False == False
False and False == False
True or True == True
True or False == True
False or False == False
print(True and True)
# prints True
print(True or False)
# prints True
We can nest logical expressions using parentheses.
print((True or False) and False)
First, we evaluate the expression in the parentheses, (True or False)
. It evaluates to True
:
print(True and False)
True and False
evaluates to False
:
print(False)
So, print((True or False) and False)
prints "False" to the console.
What does this code statement evaluate to?
((True and True) or (True and False))