CHAPTER 15   •   PYTHON

Python Comparison Operators

Learn how to compare values.

01 What is this?

Learn how to compare values.

02 Syntax

Python Syntax
a == b

03 Example

Python Example
age = 20

print(age == 20)
print(age > 18)
print(age < 18)

04 Important Points

Comparison operators return True or False.

05 Common Mistakes

Use == for comparison and = for assignment.

06 Real World Use

Comparisons are used for validation and decision-making.

07 Practice This Topic

Now try the example yourself in the AIFA Python Editor.

  • Read the example carefully.
  • Change the values.
  • Run the code.
  • Observe the output.
  • Try creating your own example.
Try It Yourself →