Getting Started
Chapter 0
When you program a computer, you have to "speak" in a language your computer understands: a programming language. There are lots and lots of different languages out there, and many of them are excellent. In this tutorial I chose to use my favorite programming language, Python.
When you write something in a human language, what is written is called text. When you write something in a computer language, what is written is called code. I have included lots of examples of Python code throughout this tutorial, most of them complete programs you can run on your own computer. To make the code easier to read, I have colored parts of the code different colors. (For example, numbers are always green.) Anything you are supposed to type in will be in a dotted box, and anything a program prints out will be in a grey box.
If you come across something you don't understand, or you have a question which wasn't answered, write it down and keep reading! It's quite possible that the answer will come in a later chapter. However, if your question was not answered by the last chapter, I will tell you where you can go to ask it. There are lots of wonderful people out there more than willing to help; you just need to know where they are.
But first we need to download and install Python onto your computer.
Macintosh Installation
In order to program, you need to be able to write programs and to run programs. To do this, you will need a text editor and a command line.
Your command line is accessible through the Terminal application (found in Applications/Utilities).
For a text editor, you can use whatever one you are familiar or comfortable with. My favorite text editor is Sublime Text. Do not use TextEdit, however. Otherwise your programs may not work.
If you have Mac OS X 10.2 (Jaguar) or later, then you already have Python on your system. However, it may be an old version of Python. See what version of Python you are running by opening your command line and typing: python --version. If you see the version is less than 3, you need to Download Python. You can tell if you have version 3 because the output will be Python 3.x.x, where 'x' are numbers.
And that's it! You're all set to learn to program.
Windows Installation
The Windows installation of Python is a breeze. First, you need to download Python. There might be a couple of versions to choose from. Get the most latest available. Then simply run the installation program. It will ask you where you want to install Python. Unless you have a good reason for it, I would just install it in the default location.
In order to program, you need to be able to write programs and to run programs. To do this, you will need a text editor and a command line. My favorite text editor is Sublime Text.
It would also be a good idea to create a folder somewhere to keep all of your programs. Make sure that when you save a program, you save it into this folder.
To get to your command line, select Command Prompt from the Accessories folder in your start menu. You will want to navigate to the folder where you are keeping your programs. Typing cd .. will take you up one folder, and cd foldername would put you inside the folder named foldername. To see all of the folders in your current folder, type dir /ad.
And that's it! You're all set to learn to program.
Linux Installation
First, you will want to check and see if you have Python installed already. Type which python. If it says something like /usr/bin/which: no python in (...), then you need to download Python, otherwise see what version of Python you are running with python --version. If it is older than the latest stable build on the above download page, you might want to upgrade.
If you are the root user, then you probably don't need any instructions for installing Python. If you aren't, you might want to ask your system administrator to install it for you. (That way everyone on that system could use Python.)
And that's it! You're all set to learn to program.