Learning to Program in Python for Kids

of all ages and Linux on a Raspberry Pi by Philip M Russell


So what is a variable?

These things are what makes computer programes work

Lets us see if we can make some


Variables are little boxes inside the memory of the computer that store things.

Lets make on and put something in it.


Here is a simple program

box = 1 # Put 1 in a box

This line makes a variable box and puts the number 1 in it.

print box

We Print out what is in the variable box.

Here is the code

box = 1 
print box

Pi Python Character Whats that thing after the 1

This is a comment. It doesn't do anything for the program. It is here to help you understand what is going on.

Lets make the program a bit easier to read.

Simple ExamplePi Python Character

In this example I have made the program easier to read by putting in two types of print command together. to show you how it works. If you print a name the computer thinks you are talking about a variable and prints the contents of the box. If the text is in quotes then it prints what is oin the quotes exactly as it is written. There are different types of quotes that do different things but we will look at this more here.

Placing text in a variable Pi Python Character

What happens if we put text in a box?

Here is the code

name = "Pi"
print name

Easy the computer prints out the text.

We will have to learn more about this later on when we get to loops.