Python ยท Lesson 3 of 5
๐ฆ Making decisions with if
Run different code depending on a condition.
if checks a condition. If it is true, the indented lines run. else runs when it is false.
marks = 72
if marks >= 60:
print("You passed! ๐")
else:
print("Keep practising!")OUTPUTYou passed! ๐
Use == to check if two things are equal, != for not equal, and > < >= <= to compare.
๐ก The lines inside if must be indented (moved right) by 4 spaces.
โ๏ธ Your turn
Open this example in the playground, change it and run it.
๐ง Quick quiz