Mission 1 ยท Lesson 3

Making Decisions: If/Else

Conditions ยท Branches ยท Logic

+40 XP on completion
โœ“ You completed this lesson โ€” 40 XP earned.
01

What If Means in Code

Computers make decisions using if statements. Type this exactly. Run it, then change the score number and run it again.

score = 85 if score >= 90: print("Rank: S") elif score >= 75: print("Rank: A") else: print("Rank: B")
02

Understand the Logic

If is the first condition to check. Elif means another condition if the first was false. Else is what happens if nothing matched. Python checks top to bottom and stops at the first true condition.

if = first check elif = another check else = fallback path
03

Build Your Own

Create a program that takes a health_points variable and prints one of three messages: "Full Health" if above 75, "Low Health" if above 25, and "Critical" if 25 or below.

health_points = 40 if health_points > 75: print("Full Health") elif health_points > 25: print("Low Health") else: print("Critical")

Complete all three steps first.

โฌก

40 XP Earned!

Your code just made a decision. That's logic.

Paste your health points program here