Using Python

To begin using Python you should go to Applications on your Hard Drive and find Mac Python 2.5. Open that folder and inside you will find IDLE.

Start IDLE by double clicking on it. When you do this you will see a "Python Shell" window appear.

The Python Shell is like a calculator. We can use it to solve the problem to the right.

In the shell we can store values in named locations called variables.

Computing Area

Learning to program in Python is like learning to use your calculator. In fact Python programming and using your calculator are quite similar. Python can be used to compute with numbers. Numbers like 3.0 are called floating point or real numbers in Python. Numbers like 3 are called integers in Python. Real numbers include a decimal point and integer numbers do not.

In this first problem we'll use Python to solve a problem involving multiplication and subtraction.

Computing the area of shapes constructed of overlapping regular polygons.

Consider the shape shown here. In the figure all angles are right angles and all distances are in meters. Our job is to figure out the area in square meters. The lighter lines in the middle help us figure out how to compute the area. We can compute the area of the two rectangles and then subtract one of the overlapping parts since otherwise the overlapping part would be counted twice.

You Try It

Try opening IDLE and try these commands out in the Python Shell. You might notice you can't go back and fix errors very easily. We'll learn how to write programs the right way in the next lesson.

>> Next Lesson