Lesson 1

🖨️ Print Basics - Talking to Python

Learn how to use print() to display messages!

📖 What is Print?

The print() function is like Python's voice! It shows messages on your screen. You can print text, numbers, or almost anything!

Printing Text

To print text (words), put your message inside quotation marks " " or ' '

print("Hello, World!")
print('I love Python!')
print("ROBie is my friend")

Multiple Print Statements

Each print() creates a new line!

print("Line 1")
print("Line 2")
print("Line 3")

🎯 Quick Quiz

Question: What do you need to put around text when using print()?

💻 Try It Yourself!

Write a print statement that says "I am learning Python!"

✍️ Code Editor
Lesson 2

🔢 Print Numbers - Math with Python

Learn how to print numbers and do calculations!

📖 Printing Numbers

You can print numbers WITHOUT quotation marks! Python knows they're numbers.

print(42)
print(3.14)
print(-17)

Math Operations 🧮

Python can do math! You can calculate and print the result:

print(5 + 3) # Addition: shows 8
print(10 - 4) # Subtraction: shows 6
print(6 * 7) # Multiplication: shows 42
print(15 / 3) # Division: shows 5.0

Mixing Text and Numbers

You can use commas to print both text and numbers:

print("I am", 12, "years old")
print("The answer is:", 5 + 5)

🎯 Quick Quiz

Question: What does print(4 + 6) show on the screen?

💻 Try It Yourself!

Print the result of 7 multiplied by 8 (use the * symbol)

✍️ Code Editor
Lesson 3

📦 Creating Variables - Data Containers

Learn how to store information in variables!

📖 What are Variables?

Variables are like labeled boxes where you can store information. You can use that information later!

Creating a Variable

Use the equals sign = to create a variable:

name = "Alex" # Text variable
age = 12 # Number variable
score = 95.5 # Decimal number

No Declaration Needed! 🎉

In Python, you DON'T need to say "this is a variable" first. Just assign a value and boom - it's created!

x = 5 # Created right here!
message = "Hello!" # Another one!
print(x) # Shows: 5
print(message) # Shows: Hello!

Variables Can Change

You can change what's stored in a variable anytime:

score = 10
print(score) # Shows: 10
score = 20 # Changed!
print(score) # Shows: 20

🎯 Quick Quiz

Question: What symbol do we use to create a variable?

💻 Try It Yourself!

Create a variable called robot_name and set it to "ROBie"

✍️ Code Editor
Lesson 4

✏️ Naming Variables - The Rules

Learn the rules for naming your variables!

📖 Variable Naming Rules

Python has important rules for naming variables. Follow them or your code won't work!

✅ The Rules (you MUST follow these!)

  • ✅ Start with a letter (a-z, A-Z) or underscore (_)
  • ✅ After the first character, you can use letters, numbers, or underscores
  • ✅ Variable names are case-sensitive: age and Age are different!
  • ❌ Cannot start with a number
  • ❌ Cannot use spaces
  • ❌ Cannot use special characters like !, @, #, $, %

Good Variable Names ✅

my_age = 12 # Good!
player1 = "Alex" # Good!
_score = 100 # Good!
firstName = "Sam" # Good! (camelCase)
first_name = "Sam" # Good! (snake_case)

Bad Variable Names ❌

# 2fast = 100 # BAD! Starts with number
# my-age = 12 # BAD! Has dash -
# my age = 12 # BAD! Has space
# my@score = 5 # BAD! Has @ symbol

Best Practices 🌟

Make your variable names descriptive! Others (and future you) will thank you.

x = 12 # OK but what is x?
student_age = 12 # Much better! Clear!

🎯 Quick Quiz

Question: Which variable name is CORRECT?

💻 Try It Yourself!

Create a variable with a good name for a student's grade. Make it descriptive!

✍️ Code Editor
Lesson 5

🎯 Multiple Variables - Many at Once

Learn shortcuts to create many variables quickly!

📖 Assign Multiple Values

Python lets you create multiple variables in ONE line! This is super useful.

Three Variables, Three Values

You can assign three (or more) values to three variables at once:

x, y, z = 1, 2, 3
print(x) # Shows: 1
print(y) # Shows: 2
print(z) # Shows: 3

One Value to Multiple Variables

Give the SAME value to multiple variables:

a = b = c = 100
print(a) # Shows: 100
print(b) # Shows: 100
print(c) # Shows: 100

Mix Different Types

You can assign different types of data all at once:

name, age, height = "Alex", 12, 1.5
print("Name:", name)
print("Age:", age)
print("Height:", height)

🎯 Quick Quiz

Question: What does this code do? a, b, c = 5, 10, 15

💻 Try It Yourself!

Create three variables (red, green, blue) and assign them the values 255, 128, 0 in one line

✍️ Code Editor
Lesson 6

📊 Output Variables - Printing Data

Learn different ways to print variables!

📖 Printing Variables

There are many cool ways to print variables and combine them with text!

Simple Variable Print

Just put the variable name inside print():

name = "ROBie"
print(name) # Shows: ROBie

Print Multiple Variables

Use commas to print multiple variables. Python adds spaces automatically!

first_name = "Alex"
last_name = "Smith"
print(first_name, last_name) # Shows: Alex Smith

Mix Text and Variables

Combine your own text with variables:

age = 12
print("I am", age, "years old")
# Shows: I am 12 years old

The + Operator for Strings

You can use + to join strings (text) together:

first = "Hello"
second = "World"
print(first + " " + second) # Shows: Hello World

⚠️ Warning: Numbers and Strings

You CANNOT use + to mix numbers and text directly. Python will get confused!

age = 12
# print("Age: " + age) # ERROR! Can't mix!
print("Age:", age) # This works! Use commas!

🎯 Quick Quiz

Question: What's the correct way to print a variable called score with text?

💻 Try It Yourself!

Create two variables: favorite_game and hours_played, then print them together with text!

✍️ Code Editor
Lesson 7

🌍 Global Variables - Everywhere Access

Learn about variables that work everywhere in your code!

📖 What are Global Variables?

Global variables are created OUTSIDE of functions. They can be used anywhere in your code!

game_name = "Python Quest" # Global variable
def show_game():
print("Playing:", game_name) # Can use it here!
show_game() # Shows: Playing: Python Quest

Local vs Global 🎯

Variables created inside functions are LOCAL - they only work inside that function!

score = 100 # Global - works everywhere
def play_game():
level = 5 # Local - only inside function
print(score) # Can use global here ✅
print(level) # Can use local here ✅
print(score) # Works! ✅
# print(level) # ERROR! ❌ level doesn't exist here!

The global Keyword 🔑

If you want to CHANGE a global variable inside a function, use the global keyword:

points = 0 # Global variable
def add_points():
global points # Tell Python we want to change the global one
points = points + 10
print(points) # Shows: 0
add_points()
print(points) # Shows: 10 (changed!)

🎯 Quick Quiz

Question: Where can you use a global variable?

💻 Try It Yourself!

Create a global variable called player_name and assign it your name!

✍️ Code Editor
Lesson 8

🎓 Variable Practice - Test Your Skills

Put everything together with practice exercises!

📖 Let's Practice!

Now it's time to use everything you've learned! Complete these challenges.

Challenge 1: Create Variables

Can you create these variables?

  • A variable for your name
  • A variable for your age
  • A variable for your favorite number
# Try writing this yourself!
my_name = "..."
my_age = ...
favorite_number = ...

Challenge 2: Variable Math

Create two number variables, then print their sum!

number1 = 25
number2 = 17
print("Sum:", number1 + number2)

Challenge 3: Update Variables

Variables can change! Update them and print:

score = 50
print("Starting score:", score)
score = score + 25 # Add 25 points!
print("New score:", score)

🎯 Quick Quiz

Question: What happens when you run: x = 5, then x = x + 3?

💻 Final Challenge!

Create a mini program: Make variables for your name, age, and favorite hobby. Then print a sentence using all three!

✍️ Code Editor
Lesson 9

🎨 Data Types - Different Kinds of Data

Learn about the different types of data Python uses!

📖 What are Data Types?

Data comes in different types! Just like how you have toys, books, and clothes - Python has different types of data.

Common Data Types 🎯

1. String (str) - Text/words

name = "ROBie" # String
message = 'Hello World' # Also a string

2. Integer (int) - Whole numbers

age = 12 # Integer
score = -5 # Negative integer

3. Float - Decimal numbers

height = 1.5 # Float
pi = 3.14159 # Float

4. Boolean (bool) - True or False

is_student = True # Boolean
is_adult = False # Boolean

Checking Data Types 🔍

Use the type() function to see what type a variable is:

name = "Alex"
print(type(name)) # Shows: <class 'str'>
age = 12
print(type(age)) # Shows: <class 'int'>
height = 1.5
print(type(height)) # Shows: <class 'float'>

Why Types Matter ⚡

Different types work differently! You can add numbers, but adding a number to text causes errors:

print(5 + 3) # Works! Shows: 8
print("Hello" + " " + "World") # Works! Shows: Hello World
# print(5 + "hello") # ERROR! Can't mix types!

🎯 Quick Quiz

Question: What data type is the number 3.14?

💻 Try It Yourself!

Create four variables, one of each type (str, int, float, bool), and use type() to check them!

✍️ Code Editor