💡 What You'll Learn
if statements let your program make decisions! If a condition is True, run that code block. Use else for what happens when it's False. The code inside is indented (4 spaces) to show it's part of the if block.
if_demo.py
1age = 15
2if age >= 13:
3 print("You can join the club!")
4else:
5 print("Sorry, you need to be older.")
📺 Interactive Preview - Try changing the age!
🎯 Your Challenges
1Pass/Fail
Check if a score is >= 60 and print "Pass" or "Fail"
2Eligible to Vote
Check if age >= 18 for voting eligibility
3Even or Odd
Check if a number is divisible by 2 using the modulo % operator
📚 What You Learned
if condition:runs code when condition is Trueelse:runs code when condition is False- Indentation (4 spaces) defines the code block
- Conditions use comparison operators like
>=,<,==