Truth Tables

The Python interpreter doesn't think about operators the way we do when we do math. For example, when a human sees an equation like this:

```x = 2 + 3
```

It looks like the description of a situation. A person might interpret this equation as something like "The variable x has the same value as the sum of 2 and 3". A human might want to solve for x, or might not. A human might get the answer wrong one day and then get then answer right another day.

For the Python interpreter, the statement is a procedure that must be carried out. To Python, the statement means "Find the sum of 2 and 3 and assign that value to the variable x". Every time Python is given the same statement, it will give the same answer.

The Python interpreter thinks of addition as a mini-machine that takes two numbers and uses them to produce another number, like this:

When it comes to inequality symbols, things really get weird. In math, we're used to seeing inequalities like this:

```2 > 3
```

We recognize this as a false statement. So does Python. But remember our adding machine above? It takes two numbers and produces another number. As far as Python is concerned, there is also a mini-machine for > that takes two numbers and produces a bool (True or False). So you can actually write things like this:

```x = 2 > 3
```

Here the > operator converts the 2 and the 3 into a bool value (False) and assigns that value to x.

For Python, the > is considered to be an operator, just like the +. The only difference is that the + takes two numbers and produces another number, while the > takes two numbers and produces a bool. In Pythonese, the + is called an arithmetic operator, and the > is called a comparison operator.

Notice in the figure above that there is also an operator called a boolean operator that takes two bool values and produces another bool value. The video below explains the boolean operator and builds truth tables using the operators `and` and `or`.

Watch the videos and follow along in the console

Then use the quizlet below to make sure the boolean expressions are committed to memory.

Quiz

Try this quiz on boolean operations.

Coding Practice

In the trinket below, you'll start with a `def` for a method called `sleep_in`. The function takes two arguments, `weekday` and `vacation`.

1. Remove the comment and `pass` statement. You'll replace this with your own code. Remember to indent your statements correctly!
2. Use `not` and `or` to write a correct expression with `weekday` and `vacation` and return the result.
3. Click the button to test your code.
4. Click the button as needed to get back to your code.