Beneath the magic of an if statement is another Python data type, bool, the boolean!
Python uses booleans to evaluate conditions.
A boolean variable can take on one of two values, True or False.
Using a comparison operator to check whether a condition has been met, such as x > 2, returns a boolean value.
![](https://cdn.prod.website-files.com/5dcb2c0e8fcf2859ddc3392a/5f2028585e3ec3386ce5c89e_python-32.png)
This means that once an if statement condition evaluates to True, the indented code block will run.
![](https://cdn.prod.website-files.com/5dcb2c0e8fcf2859ddc3392a/5f20286221f44fbc4b19189f_python-33.png)
Here, ’Get some food!’ is printed because the condition above evaluates to True.
Python booleans must be capitalized, and they belong to the bool class.
![](https://cdn.prod.website-files.com/5dcb2c0e8fcf2859ddc3392a/5f202870be19ec1660b1c47d_python-34.png)
Boolean Operators
There are two keywords in Python that allow us to write more complex boolean conditions.
- The and operator
![](https://cdn.prod.website-files.com/5dcb2c0e8fcf2859ddc3392a/5f20287f8fe6bb97348fbe1f_python-35.png)
When using the and operator, all conditions must evaluate to True for the code block to run.
- The or operator
![](https://cdn.prod.website-files.com/5dcb2c0e8fcf2859ddc3392a/5f2028f521f44fb2fe1945f5_python-36.png)
When using the or operator, at least one of the conditions must evaluate to True.
![](https://cdn.prod.website-files.com/5dcb2c0e8fcf2859ddc3392a/5f202902557d99040b992472_python-37.png)
![](https://cdn.prod.website-files.com/5dcb2c0e8fcf2859ddc3392a/5f228f521a602261c2fb2078_Python7.png)