0d: 00h: 00m: 00s

🎁 Get 3 extra months of learning — completely FREE

That's 90 extra days to master new skills, build more projects, and land your dream job.

Become a PRO
Background Image

🎁 Get 3 extra months of learning completely FREE

Become a PRO
Danielle Hoyle
PRO
last week
Daniellecountry asked

Do comparison operations in Python always return True or False?

Abhay Jajodia
Expert
last week
Abhay Jajodia answered

Hello Danielle, really nice question.

Any time you use a comparison in Python — things like ==, >, <, >=, and so on — Python evaluates that expression and decides whether it’s true or false. The result of that decision is always a Boolean value: True or False.

For example:

total = 150
result = total > 100
print(result)   # True

Here Python checks the comparison, finds that 150 really is greater than 100, and gives you True. If the comparison wasn’t correct, you’d get False instead.

That’s just how comparisons work in Python:
they always produce a Boolean value.

If you have further questions, I'm here to help.

Python
This question was asked as part of the Learn Python Basics course.