01. Install Python and write your first program.

You are of course free to use any Python installation you want. Maybe you already installed one, or somebody else did it for you. There are a lot of choices out there…

I’m using Anaconda Python, because it’s available for the 3 major operating systems (Windows, Linux and Mac OS). You can just download and install the version for your platform. It comes in 32 and 64 bit versions, and Python version 2.7 and 3.5. I’m using the Python 3.5 version, and so should you. Python 2.7 is going to get fased out and support will be terminated in 2020. At least, that is the idea at the moment I’m writing this.

If you have a 64 bit machine (which is most likely these days) I’d go for the 64 bit version. If you’re not sure, a 32 bit should work in any case.

You can download Anaconda here: https://www.continuum.io/downloads. Optionally, you can go through the Anaconda test drive, take the conda 30-minute test drive.

Once installed, you can open the Anaconda navigator, and start up Spyder, which is the IDE I’ll use to program in. See below for a picture of the navigator.

anacondaNavigator

To test the installation, make a new file and type the following text in the Spyder window:

print (“Hello world!”)

Don’t copy & paste the text above, because you’ll run into trouble with the fancy rounded double quotes! Just type it in the Spyder window, you’ll get straight quotes there. Besides, typing commands helps you remember them, while copy & paste doesn’t do anything for your memory.

Save the file somewhere (with a name of your choice, I just used the proposed name “untitled0.py”), and then run it. To run the file, first do the following: click on “Run”, then on “Configure”.

spyder

In the “Configure” window, choose “Execute in a new dedicated Python console”, leave the rest as is, and hit the OK button.

You may choose to tick the last option too: “Always show this dialog on a first file run”. I didn’t here, but that means I’ll have to do this again for the next program I’ll write.

spyderConfigure.png

After this, to run your program, you can click on the green run triangle or just hit the F5 key (which is what I prefer). You’ll see the text “Hello World!” in the output window (right below, I highlighted it).

Tip: if you ever mess up the window layout in Spyder, go to “View”, and choose “Reset window layout”.

HelloWorld

And there you go, you’ve written your first Python program. Easy, no?

Leave a comment