Using an if statement with a non-Boolean type will cast it to a Boolean. In other words, the following two statements are always equivalent:
if a:
...
if bool(a): # exactly the same as above
...
A typical example is testing whether a list is empty:
# L is a list
if L:
print("list not empty")
else:
print("list is empty")
An empty list, or tuple, will return False.
You can also use a variable in the if statement, for example, an integer:
# n is an integer
if n % 2: # the modulo operator
print("n is odd")
else:
print("n is even")
Note that we used % for the modulo operation, which returns the remainder of an integer division. In this case, it returns 0 or 1 as the remainder after modulo 2.
In this last example, the values 0 or 1 are cast to bool; see also Section 2.3.4, Booleans and integers.
The Boolean operators or, and, and not will also implicitly convert some of their arguments to a Boolean.