KIIT Polytechnic logo Students Hub KIIT Polytechnic Sign in
▲The Board ◆Notes ≡Syllabus ▦Timetable ?Doubts ▶Reels 🎮Learn 🐍Courses ◈Opportunities ✍Blog ▮Store ★Team ⌕Search
← Learn to Code — Python for Beginners Module · Making Decisions

if, elif, else

Now let's use those True/False comparisons to make a program branch.

marks = 78

if marks >= 90:
    print("Excellent")
elif marks >= 60:
    print("Good")
else:
    print("Keep practising")

A few rules Python is strict about:

  • The line with if ends in a colon :
  • Whatever runs "inside" the if must be indented (usually 4 spaces) — Python uses indentation to know what belongs together
  • elif means "else if" — check another condition if the first wasn't true
  • else catches everything else

Try it: change the marks value below and run it a few times to see different outputs.