On Thu, 22 Sep 2016 01:46 pm, Sayth Renshaw wrote: > What about 0 or 1 they are true and false like no other numbers? what > category do they fall in with regards to booleans?
0 and 1 are ints: py> type(0) <class 'int'> py> type(1) <class 'int'> just like 2, 3, 4, -1, -999, 1098765432 etc. But just like 1 == 1.0 (a float), and 0 == 0.0 (a float), and in fact 1 also equals Fraction(1, 1) and Decimal(1) and 1+0j (complex number), so 1 also equals the bool True and 0 equals the bool False. The reason for this is that in many programming languages, there are no boolean values. People use 0 for false and 1 (or sometimes -1) for true. In the early days, Python was the same. See https://www.python.org/dev/peps/pep-0285/ for more details. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list