Tutorials

Python 3 Tutorial

All Tutorials Learning Tools Login

Python 3 Tutorial · Chapter 10 of 22

Python If Else

Make decisions with conditions.

An if statement runs a block only when a condition is true. else handles the false path.

Use this for pass/fail checks, validation, and simple classification.

If/else sample Try it Yourself »
score = int(input("Enter score: "))
if score >= 75:
    print("Passed")
else:
    print("Failed")

Classroom Tips

  • Indent the body under if/else.
  • Do not confuse = with ==.