-1

How to use "not" and "and" with comparison operators? I have never seen them before? I thought you only use "not" and "and" in a loop or under some if statements? Are there any more examples of this? What is this called?

Anyway why is not 4 > 2 and 2 < 3, false?

Sarah V.P
  • 121
  • 4
  • 1
    See https://docs.python.org/3/reference/expressions.html#boolean-operations and https://docs.python.org/3/reference/expressions.html#operator-precedence. – jonrsharpe Nov 15 '21 at 08:54

1 Answers1

0

In short, it is down to Python operator precedence and the general rules of statement logic:

  (not 4 > 2) and 2 < 3
#      +++++ 
#      True 
# +++++++++++     +++++
#   False         True
# +++++++++++++++++++++
#         False
user2390182
  • 72,016
  • 6
  • 67
  • 89