Practice: Answers

Here are the answers to the comparisons on the last page:

>>> 5 < 4 + 3
True
>>> 12 + 1 >= 12
True
>>> 16 * 2 == 32
True
>>> 16 != 16
False
>>> 5 >= 6
False

The first thing you probably noticed is that the answers you got back aren't numbers.

Well that makes sense, right? If we're asking if one number is greater than another, the answer is going to be either True or False, something we call a Boolean. We'll talk about Booleans in more detail a little later on.

One other thing we should talk about here is something called the order of operations.

Let's look at the first expression: 5 < 4 + 3

When the computer reads that expression, do you think it sees this?:

"Is five less than four? Then add 3."

Hopefully not, because the answer to "Is five less than four?" is False, and you can't add 3 to that.

Instead, Python does the adding first. 4 + 3. And 4 + 3 is 7, so what this expression is really asking is:

"Is five less than seven?"

So here's another rule about doing math with Python:

Simple expressions like adding or multiplying will always be calculated before any the comparisons.