Course Content
Week 1: Getting Started
In week 1 the basis goal is to get started with the basics.
0/2
Week 2: Variables & Data Types
Variables are containers that computer programs use to store information pertinent to what that computer program will do. Data Types are the different types of Variables and how Python uses these variables when building logic
0/2
Week 3: Making Decisions
In both computer programs and the AI world, computer programs need a way to make decisions. Booleans and Conditionals provide a way to make this happen.
0/2
learning Python Programming and also Intro to Games

Lesson 5: Boolean Logic and if Statements

Topics Covered:

  • Understanding True and False
  • Using comparison operators
  • Writing simple if statements to control program flow

What is Boolean Logic?

Boolean values are either True or False. They are used to make decisions in a program.

Comparison Operators

  • == equal to
  • != not equal to
  • > greater than
  • < less than
  • >= greater than or equal to
  • <= less than or equal to
print(5 == 5)     # True
print(3 > 10)     # False
print(7 != 2)     # True

Using if Statements

An if statement lets you run code only if something is true.

age = int(input("How old are you? "))

if age >= 13:
    print("You're a teenager!")

Example: Favorite Animal Checker

animal = input("What is your favorite animal? ")

if animal == "dog":
    print("Dogs are awesome!")

Challenge Task

  • Ask the user for their test score (0–100).
  • If the score is 50 or higher, say “You passed!”.
  • Otherwise, say “Try again next time.”
score = int(input("Enter your score: "))

if score >= 50:
    print("You passed!")
else:
    print("Try again next time.")