Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
PYTHON FOUNDATIONS / CHAPTER 01 / Learn / LESSON 04
Fourth class. A comparison asks a question and Python answers with a bool: True or False.
The <, <=, >, and >= operators compare order. == checks whether two values are equal, while != checks whether they differ. Do not confuse == with =: one equals sign assigns a value; two compare.
You can store the result:
temperature = 21
warm = temperature >= 20
print(warm)warm is a bool whose value is True. The same pattern can mark whether a score passes a threshold, stock is exhausted, or BMI is below a boundary.
This lesson only creates and prints boolean results. In the next lesson, if will use such results to choose different paths.
Common mistakes: using = instead of == for equality, or writing the string "True" instead of the boolean True.
The <, <=, >, >=, ==, and != operators compare values and return True or False.
DECISION STANDBY
›