Lesson 7 of 34

Comparisons: True or False

6 min 20 XP

When you compare two values, Python answers with True or False. These are called Booleans.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

= stores a value (assign). == asks “are these equal?” (compare). Don't mix them up!

You can compare strings too, but capitals matter: "Chennai" and "chennai" are not equal.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

Challenge

+20 XP

price = 499 and budget = 500. On the first line, print whether price is less than budget (<). On the second line, print whether price equals 500 (==).

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.