To open IDLE on Windows, click on Start, then Programs, then Python 3.1, then IDLE (Python GUI). With IDLE open, let's do some simple math with Python. The interactive shell can work just like a calculator. Type 2+2 into the shell and press the Enter key on your keyboard. (On some keyboards, this is the Return key.) As you can see in Figure 2-1, the computer should respond with the number 4; the sum of 2+2.
+.. e:: images/2-1.png
-Figure 2-1: Type 2+2 into the shell.
+Figure 2-1: Type 2+2 into the shell.
As you can see, we can use the Python shell just like a calculator. This isn't a program by itself because we are just learning the basics right now. The + sign tells the computer to add the numbers 2 and 2. To subtract numbers use the - sign, and to multiply numbers use an asterisk (\*), like so:
Figure 2-2 is what the interactive shell in IDLE will look like after you type in the instructions above.
+.. e:: images/2-2.png
-Figure 2-2: What the IDLE window looks like after entering instructions.
+Figure 2-2: What the IDLE window looks like after entering instructions.
These math problems are called expressions. Computers can solve millions of these problems in seconds. Expressions are made up of values (the numbers) connected by operators (the math signs). Let's learn exactly what values and operators are.
Numbers are a type of value. Integers are a type of number. But, even though integers are numbers, not all numbers are integers. (For example, fractions and numbers with decimal points like 2.5 are numbers that are not integers.)
+.. figure:: images/2-3.png
+ Figure 2-3: An expression is a
+ made up of values and operators.
This is like how a cat is a type of pet, but not all pets are cats. Someone could have a pet dog or a pet hermit crab. An expression is made up of values (such as integers like 8 and 6) connected by an operator (such as the * multiplication sign). A single value by itself is also considered an expression.
-.. image:: images/2-3.png
-Figure 2-3: An expression is a made up of values and operators.
In the next chapter, we will learn about working with text in expressions. Python isn't limited to just numbers. It's more than just a fancy calculator!
-.. image:: images/2-4.png
-Figure 2-4: Variables are like boxes that can hold values in them.
+.. figure:: images/2-4.png
+ Figure 2-4: Variables are like boxes that can hold values in them.
You can think of the variable like a box with the value 15 inside of it (as shown in Figure 2-4). The variable name "spam" is the label on the box (so we can tell one variable from another) and the value stored in it is like a small note inside the box.