Game Development Reference
In-Depth Information
2 - The Interactive 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:
Table 2-1: The various math
operators in Python.
2+2
addition
2-2
subtraction
2*2
multiplication
division
2/2
When used in this way, +, -, *, and / are called operators because they tell the
computer to perform the specified operation on the numbers surrounding them.
Integers and Floating Point Numbers
In programming (and also in mathematics), whole numbers like 4, 0, and 99 are called
integers . Numbers with fractions or decimal points (like 3.5 and 42.1 and 5.0) are not
integers. In Python, the number 5 is an integer, but if we wrote it as 5.0 it would not be an
integer. Numbers with a decimal point are called floating point numbers . In
mathematics, 5.0 is still considered an integer and the same as the number 5, but in
computer programming the computer considers any number with a decimal point as not an
integer.
Search WWH ::




Custom Search