Getting Started With Python Programming
This guide takes you through the process of getting started with programming using the Python language. The sections flow from one to the next so it's recommended to read through this document linearly.
1. Download the installer:
- For Windows 32-bit (if you're uncertain, this is probably the version you should download) : http://www.python.org/ftp/python/3.1.2/python-3.1.2.msi
- For Windows 64-bit: http://www.python.org/ftp/python/3.1.2/python-3.1.2.amd64.msi
- For Mac OS X: http://www.python.org/ftp/python/3.1.2/python-3.1.2-macosx10.3-2010-03-24.dmg
2. Run the installer. 3. Click next for every option in the setup wizard (i.e. use the defaults).
Using the Idle Command Line
The Python installation comes with an easy-to-use text editor called Idle. You should start by playing around with this. You should be able to find Idle wherever Python was installed. On Mac this should be in the Applications folder while on Windows it should be accessible from the Start menu in a folder named Python or something close to that.
When you first open Idle, you'll see the command line:
The command line is very useful for quick math and short sequences of commands:
Take some time to play around with the Python command line.
The Idle Text Editor and Your First Python Program
For most programming needs, you'll want to edit your program in a separate document and then run it. In the file menu click on New Window which should give you a blank document with the title "Untitled". To get acquainted with the text editor, let's write our first Python program! We'll write a program to solve the | first Euler Project problem which asks:
Find the sum of all the multiples of 3 or 5 below 1000.
Our basic strategy will be to add up all the multiples of 3 below 1000, then add to that the multiples of 5, and then subtract out the multiples of 15 since they will have been counted twice.