CHAPTER 2

Magic Boxes (Variables) ๐Ÿ“ฆ

A great wizard has thousands of potions. ๐Ÿงช If he puts them all on the floor, he will lose them!

In Python, we use Variables to organize things. Think of a variable as a Magic Box with a label on it. You can put something inside, and find it later just by reading the label.

โœจ Creating a Box

To create a box, you give it a name, use the = sign, and then put something in it.

hero_name = "Cody"

Now, whenever you type hero_name, the computer sees "Cody"!

print(hero_name)

๐Ÿ‘‰ Notice: We don't use quotes when printing the box name. If you use quotes print("hero_name"), it will print the word "hero_name", not "Cody"!

YOUR QUESTS โš”๏ธ

Quest 1: The Name Box

Create a variable called my_name and put your name in it. Then print it.

my_name = "Wizard Alex"
print(my_name)
Waiting for you to run code...

Quest 2: The Transformation

Now change what is inside the box! Change my_name to "Super Coder" and print it again.

my_name = "Super Coder"
print(my_name)
Locked ๐Ÿ”’
โ“

Wizard's Exam ๐Ÿ“œ

1. If score = 100, what is inside the box named "score"?

2. How do you save "Cat" into a box named 'pet'?

โŒจ๏ธ EDITOR
Waiting for code...