Python Learning Series · @onlysamarrr · Day 5 / 30
Day 5 teaches comparison and logic. Comparison operators (==, !=, >, <, >=, <=) return True or False, and and, or and not combine conditions. Note: = assigns, == compares.
Phase: Beginner · Reels: 21/450 – 25/450
Day 5 teaches comparison and logic. Comparison operators (==, !=, >, <, >=, <=) return True or False, and and, or and not combine conditions. Note: = assigns, == compares.
x = 7
print(x == 7)
print(x != 7)
print(x > 5 and x < 10)
print(x < 5 or x > 10)
print(not (x > 10))
print(5 < x < 10)
print(bool(0), bool(""), bool("0"), bool([]))
True False True False True True False False True False
Login checks, age gates and discount rules are all built from comparison and logical operators.
Select (tick) an option, then tap Check answer to see instantly whether your answer is right or wrong, with an explanation. You can change your answer and check again.
Q1. Which operator compares two values?
Q2. What is True and False?
Q3. What is bool("")?
| 21/450 | Concept | == != > < operators |
| 22/450 | Live demo | and, or, not live |
| 23/450 | Common mistake | = vs == galti |
| 24/450 | Quiz | Quiz: True ya False? |
| 25/450 | Interview / real life | Interview: truthy aur falsy values |
Note: In the Excel file, two Day 5 reel titles were blank, so those two titles were taken from the example Roadmap PDF for the same day, topic and order. All other titles come exactly from the Excel file.