Hey players! 👋 Welcome to Day 9. Up until now, our scripts have been a one-way street—Python just runs line 1, then line 2, then line 3. But real programming requires making decisions.
Is the user's password correct? Is the player's health less than or equal to 0? Is their age over 18?
Before our code can make decisions, it needs to learn how to compare things. Comparison operators look at two pieces of data and output a pure Boolean: True or False. Let's meet the operators! ⚖️
⚖️ The Comparison Lineup
Here are the six basic symbols you'll use to compare values in Python:

⚠️ The Absolute Biggest Beginner Pitfall
Look closely at the "Equal to" symbol: ==.
A single equals sign (=) is used to assign a value to a box (e.g., score = 100).
A double equals sign (==) is used to ask a question (e.g., "Is the score equal to 100?").
Using = when you meant to use == is an absolute rite of passage error that will cause Python to throw a dramatic syntax fit. Keep your eyes peeled!
my_score = 45
winning_score = 100
# Checking if we won yet 🏆
print(my_score == winning_score) # Prints: False
print(my_score != winning_score) # Prints: True
🚀 Today's Challenge 🏆
Create a variable called required_height = 150.
Create another variable called rider_height = 165.
Use a comparison operator to check if the rider is tall enough to ride the roller coaster (i.e., rider_height is greater than or equal to required_height).
Print the result and make sure it says True!
Tell me if your rider passed the height check in the comments! Tomorrow, we combine multiple conditions using Logical Operators! 🔀
Top comments (0)