KIIT Polytechnic logo Students Hub KIIT Polytechnic साइन इन
▲बोर्ड ◆नोट्स ≡सिलेबस ▦टाइमटेबल ?डाउट ▶रील्स 🎮सीखें 🐍कोर्स ◈मौके ✍ब्लॉग ▮स्टोर ★टीम ⌕खोजें
← Learn to Code — Python for Beginners मॉड्यूल · 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.