How does a computer decide if you are allowed to log into a website or check your bank account balance? In this video, we dissect comparison operators in Python.
You'll learn the six essential comparison symbols, the difference between value assignment (=) and value comparison (==), and how Python evaluates mathematical conditions to return Boolean values (True or False).
📝 CODE WRITTEN IN THIS VIDEO:
--------------------------------------
Assignment vs Equality Check
x = 10
y = 5
print(x == y) # False
Inequality Check (Not Equal)
print(x != y) # True
Greater and Less than Comparisons (using text placeholders for symbols)
print(x greater_than y) # True
print(x less_than y) # False
Greater/Less than or Equal
print(x greater_than_or_equal y) # True
print(x less_than_or_equal y) # False
🧠 BONUS CHALLENGES:
--------------------------------------
Test your comparison logic! Comment your answers below.
Challenge 1:
What is the output of this code?
a = 15
b = 15
print(a greater_than b)
print(a greater_than_or_equal_to b)
Options:
A) True, True
B) False, True
C) True, False
Challenge 2:
What is the output of this code?
x = "Python"
y = "python"
print(x == y)
Options:
A) True
B) False (hint: check the capitalization case!)
C) Error
#python #programming #coding #pythontutorial #learnpython #compsci