-1

Why is print(0<0<2) false? Which does it compute first 0<0 and then false<2 or the entire statement together?

Also, why is print(False<2) True?

Also, print(False<True) True?

wim
  • 302,178
  • 90
  • 548
  • 690
Fairy
  • 101
  • 1
  • 10
  • 3
    Please prefer asking a single question per question. When there's 3 questions in one post, it can't be effectively deduplicated, and you can't easily accept a single answer. – that other guy Jan 27 '20 at 22:37

1 Answers1

0

Why is print(0<0<2) false?

wim linked a really interesting post that answers this question ( here )

why is print(False<2) True?

Because the < operator evaluates False as 0 in this specific circumstance

[Why is] print(False<True) True?

Because False is evaluated as 0 and True is evaluated as 1. Therefor 0<1 is true

John Kugelman
  • 330,190
  • 66
  • 504
  • 555
arshbot
  • 7,909
  • 10
  • 35
  • 62
  • Note the "Answer Well-Asked Questions" section of [How to Answer](https://stackoverflow.com/help/how-to-answer), particularly the "uniquely identify the problem" phrase in the first bullet point (note: singular!), in combination with the one-question-to-a-question rules [cited by that other guy](https://stackoverflow.com/users/1899640/that-other-guy). – Charles Duffy Jan 27 '20 at 23:17
  • Not quite. `False` *is* 0, in the sense that `bool` is a subtype of `int`. – chepner Jan 28 '20 at 01:31