-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
  • 338,267
  • 99
  • 616
  • 750
Fairy
  • 101
  • 2
  • 12
  • 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
  • 349,597
  • 67
  • 533
  • 578
arshbot
  • 12,535
  • 14
  • 48
  • 71
  • 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