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.