Home › Python Tutorial › Python booleans and operators
Python booleans and operators
True, False and logic.
Comparisons give True or False. Combine them with and, or and not. Empty values ("", 0, [], None) count as False; everything else as True.
Example code
x = 10
print(x > 5 and x < 20)
print(not x == 10)
print(bool(""), bool("a"), bool(0))
print(10 / 4, 10 // 4)