- The Boolean data type is either True or False
- In python, Boolean variables are defined by True and False keywords
- In programming, one often need to know if an expression is True of False
- When two values are compared, the expression is evaluated and python returns Boolean answer
Example,
>>> print(10>9)
True
- Any string is True, except empty strings
- Any number is true, except 0
- Any list, tuple, set and dictionary are True, except empty ones
>>> bool(1)
True
>>> bool(0)
False
Views: 4