-4

The first code example prints "True" but the second code example prints "False".
They're both the same thing or not?

This prints "True":

print("f" == ("f" or "t"))

This prints "False"

print(False == (False or True))
Pitto
  • 8,229
  • 3
  • 42
  • 51
cat lat
  • 37
  • 3

1 Answers1

0

Here's a brief explanation of how the OR operator works in Python:

With the Boolean OR operator, you can connect two Boolean expressions into one compound expression. At least one subexpressions must be true for the compound expression to be considered true, and it doesn’t matter which. If both subexpressions are false, then the expression is false.

If you want to understand in a more pratical way please try this code:

print(False or True)

Output

True

For this reason your final statement would be:

print(False == True)

Output

False

Source

Pitto
  • 8,229
  • 3
  • 42
  • 51