AND Operator
The full text of this chapter, to read or revisit. To practise, do the exercises.
βΆ Do the exercisesExercise 1 β AND Operator
The and operator is a logical operator that returns True if both sides are True. Otherwise, it returns False.
Here is a truth table for the and operator with 2 variables (A and B = ?). It shows all possible combinations of True and False.
Exercise 2 β AND Operator
We can also try to display the truth table with code !
print("False and False =", False and False)
print("True and False =", True and False)
print("False and True =", False and True)
print("True and True =", True and True)Remember, and returns True only if both sides are True.
Exercise 3 β Did you get AND?
Match each formula of the left with its result on the right.
True and TrueTrue and FalseFalse and TrueFalse and FalseTrueFalseFalseFalseExercise 4 β AND Operator Quiz
What will be the result of True and False?
FalseTrueErrorNoneHint : With AND operator, both sides must be True to get True.
Exercise 5 β Match AND Results
Match each AND operation with its correct result (in these type of operations, you're gonna want to read from left to right, evaluating what's within parentheses first if there are any)
True and True and TrueTrue and False and TrueFalse and False and FalseTrue and True and FalseTrueFalseFalseFalse