Control Flow
If, Elif, Else
Syntax:
if condition:
# runs when condition is True
elif other_condition:
# runs when the first is False and this is True
else:
# runs when nothing above was Truemarks = 72
if marks >= 80:
print("Grade A")
elif marks >= 60:
print("Grade B")
elif marks >= 40:
print("Grade C")
else:
print("Keep practising")Output
Grade B
One-line if
status = "pass" if marks >= 40 else "fail"