Lesson 1

🤔 Conditions - If Statements

Learn how to make Python make decisions!

📖 The "If" Statement

An "if" statement tells Python to do something ONLY if a condition is true.

a = 33
b = 200
if b > a:
    print("b is greater than a")

⚠️ Indentation is Key!

Available space at the beginning of a code line is called indentation. Python relies on indentation (whitespace at the beginning of a line) to define scope. Other programming languages use curly-brackets for this purpose.

🎯 Quick Quiz

Question: What happens if you forget the indentation?

💻 Try It Yourself!

Write an if statement to check if 10 is greater than 5.

✍️ Code Editor
Lesson 2

↔️ Elif - Multiple Choices

What if the first condition isn't true?

📖 The "Elif" Keyword

The elif keyword is Python's way of saying "if the previous conditions were not true, then try this condition".

a = 33
b = 33
if b > a:
  print("b is greater than a")
elif a == b:
  print("a and b are equal")

🎯 Quick Quiz

Question: Can you have multiple ELIFs?

💻 Try It Yourself!

Create two variables equal to each other and use elif to check equality.

✍️ Code Editor
Lesson 3

🛑 Else - The Fallback

Catch anything that isn't caught by the preceding conditions.

📖 The "Else" Keyword

The else keyword catches anything which isn't caught by the preceding conditions.

a = 200
b = 33
if b > a:
  print("b is greater than a")
elif a == b:
  print("a and b are equal")
else:
  print("a is greater than b")

🎯 Quick Quiz

Question: Does else need a condition (like else x > y)?

💻 Try It Yourself!

Write an if/elif/else chain where the ELSE block runs.

✍️ Code Editor
Lesson 4

⚡ Short Hand - Quick Logic

If you have only one statement to execute, you can put it on the same line.

📖 Short Hand If

if a > b: print("a is greater than b")

📖 Short Hand If...Else

a = 2
b = 330
print("A") if a > b else print("B")

🎯 Quick Quiz

Question: Is Short Hand always easier to read?

💻 Try It Yourself!

Write a one-line if statement.

✍️ Code Editor
Lesson 5

🧠 Logical Operators - And, Or, Not

Combine conditional statements!

📖 And

The and keyword is a logical operator, and is used to combine conditional statements:

if a > b and c > a:
  print("Both conditions are True")

📖 Or

The or keyword is a logical operator, and is used to combine conditional statements:

if a > b or a > c:
  print("At least one of the conditions is True")

📖 Not

The not keyword is a logical operator, and is used to reverse the result of the conditional statement:

if not a > b:
  print("a is NOT greater than b")

🎯 Quick Quiz

Question: True or False? True OR False = ?

💻 Try It Yourself!

Write a condition using 'and' to check two things at once.

✍️ Code Editor
Lesson 6

📦 Nested If - Layers of Logic

You can have if statements inside if statements, this is called nested if statements.

📖 Nested If

x = 41
if x > 10:
  print("Above ten,")
  if x > 20:
    print("and also above 20!")
  else:
    print("but not above 20.")

🎯 Quick Quiz

Question: How many levels deep can you nest if statements?

💻 Try It Yourself!

Write an if statement inside another if statement.

✍️ Code Editor
Lesson 7

👻 Pass Statement - Do Nothing

if statements cannot be empty, but if you for some reason have an if statement with no content, put in the pass statement to avoid getting an error.

📖 The "Pass" Statement

a = 33
b = 200
if b > a:
  pass

🎯 Quick Quiz

Question: Does 'pass' print anything?

💻 Try It Yourself!

Write an if statement that does nothing using 'pass'.

✍️ Code Editor
Lesson 8

🚀 Real World Challenge - Space Mission

Apply everything you've learned to save the mission!

🧑‍🚀 Mission Briefing

You are the lead programmer for a Space Rocket Launch System. You need to write a Python script to check if the rocket is safe to launch.

Requirements:

  • Create a variable fuel_level (values: 0-100)
  • Create a variable weather (text: "Sunny", "Rainy", or "Stormy")
  • Logic:
    • If fuel is less than 50 or weather is "Stormy", print "ABORT LAUNCH!"
    • Elif fuel is between 50 and 75 and weather is "Rainy", print "DELAY LAUNCH"
    • Else, print "LAUNCH SUCCESSFUL!"
  • You MUST use: if, elif, else, and variables.
  • Also print the type of your variables using type() at the end.

💻 Mission Control Console

Write your mission code below. No hints this time!

✍️ COMMAND CENTER