Of course when you run the program your screen will look different
because of the raw_input statement. When you ran the program
you probably noticed (you did run the program, right?) how you had to
type in your name and then press Enter. Then the program printed out
some more text and also your name. This is an example of input. The
program reaches a certain point and then waits for the user to input
some data that the program can use later.

Of course, getting information from the user would be useless if we didn't have anywhere to put that information and this is where variables come in. In the previous program s is a variable. Variables are like a box that can store some piece of data. Here is a program to show examples of variables:

a + b is 555.4
first_name is Bill
Sorted Parts, After Midnight or Spam

Variables store data. The variables in the above program are a, b23, first_name, b, and c. The two basic types are strings and numbers. Strings are a sequence of letters, numbers and other characters. In this example b23 and first_name are variables that are storing strings. Spam, Bill, a + b is, and first_name is are the strings in this program. The characters are surrounded by " or '. The other type of variables are numbers.

Okay, so we have these boxes called variables and also data that can go into the variable. The computer will see a line like first_name = "Bill" and it reads it as Put the string Bill into the box (or variable) first_name. Later on it sees the statement c = a + b and it reads it as Put a + b or 123.4 + 432 or 555.4 into c.

Here is another example of variable usage:

a = 1
print a
a = a + 1
print a
a = a * 2
print a

And of course here is the output:

1
2
4

Even if it is the same variable on both sides the computer still reads it as: First find out the data to store and than find out where the data goes.

Notice that num was gotten with input while str was gotten with raw_input. raw_input returns a string while input returns a number. When you want the user to type in a number use input but if you want the user to type in a string use raw_input.

The second half of the program uses type which tells what a
variable is. Numbers are of type int or float (which are
short for 'integer' and 'floating point' respectively). Strings are
of type string. Integers and floats can be worked on by
mathematical functions, strings cannot. Notice how when python
multiples a number by a integer the expected thing happens. However
when a string is multiplied by a integer the string has that many
copies of it added i.e. str * 2 = HelloHello.

The operations with strings do slightly different things than
operations with numbers. Here are some interative mode examples
to show that some more.

Write a program that gets 2 string variables and 2 integer variables
from the user, concatenates (joins them together with no spaces) and
displays the strings, then multiplies the two numbers on a new line.