This is the first in a three-part series that introduces Python to beginners.

Parts 1 and 2 of the series walk through installing Python and the IDLE interface and installing Python via Anaconda, respectively. Part 3 covers the essential elements of Python so you can get started with Python ASAP.

Python is not only one of the fastest growing languages, it’s also an essential language for doing machine learning, AI, and data science.

So with all of this in mind, why wouldn’t you want to get started learning to code in Python?

🤖 Table of Contents 🤖
How to install Python
A quick tour of IDLE
Choosing the best IDE

How to install Python

Fun fact: installing Python is so easy to install that it only takes two steps.

Step 1: Check if Python is already installed on yourcomputer

Before you install Python it’s a good idea to make sure you don’t have a version already installed on your computer.

If you have a Mac, odds are you actually already have Python installed since most models now ship with it. Still, you should check what version you have and, if necessary, update it to the most recent version. More on that later.

If you have a Windows computer, you’ll probably have to install Python yourself but you should still double check that it isn’t already installed just in case.

Here’s how you check whether Python is installed on Mac:

  1. Open Spotlight.
  2. Search for Terminal and launch it.
  3. Type python into the open window.
  4. Terminal will print out the version of Python that your computer is currently running.

Here’s how to check whether you have Python installed on Windows:

  1. Go to the Windows search bar.
  2. Type in command and then select Command Prompt from the search results.
  3. Type py into the open window.
  4. If installed, Command Prompt will print your computer’s version of Python. If you see a message saying that ‘py’ is not recognized, then odds are Python isn’t installed.

Learn more about using command prompt and the command line interface here.

Currently, there are two main versions of Python, version 2.7 and those at version 3.5 or later.

Aside from a few syntactical differences, the two versions are pretty similar, however, it’s likely that support for version 2 will fade over time so all Python-based tutorials on Elle Knows Machines are written for Python 3.

It’s generally recommended to update your version of Python to the most recent version. Luckily, updating Python and installing Python from scratch follow the same process, so if either of these applies to you then keep reading 🙌

Step 2: Install Python

To install Python on Mac:

  1. Go to the Python website and download the latest version of Python for Mac here:
  2. Once it’s downloaded, launch the .pkg file by clicking on it in the download bar of your browser or by opening it from the download location on your computer.
  3. Walk through the installer – keeping all defaults ticked as they are is fine. You’ll have to agree to Python’s Terms and Conditions and the installer may also prompt you for your Mac username and password.
  4. Your computer should open the Python 3.X folder. If not, you can find it in the Applications folder.
  5. Double-click IDLE to launch Python.

To install Python on Windows:

  1. Go to the Python website and download the latest version of Python for Windows here:
  2. Once downloaded, click on the .exe file to launch the installer.
  3. Walk through the installer – keeping all defaults ticked as they are is fine. You’ll have to agree to Python’s Terms and Conditions and the installer might also prompt you for your Windows username and password.
  4. Go to the Windows search bar and type IDLE. Clicking on this will open Python. Alternatively, you can go to Start > Python > IDLE.

A quick tour of IDLE

IDLE is what’s known as an integrated development environment (IDE) and automatically comes bundled with installs of Python. We’ll talk a little bit more about what IDEs are in the next section, but basically, IDLE is a text editor that allows you to instantly begin writing and editing Python code and is hands down the quickest and easiest way to get started with Python on your own computer.

IDLE has two main parts: the shell and the editor window, both of which we’ll take a tour of now ✨

The shell

When you open IDLE the shell window is the first thing to pop up.

The first lines in the shell show you what version of Python you’re running, which at the time of writing in my case is version 3.7.0

You can then type your code directly into the window, hit enter, and it will run straight away.

This is a good place to test out quick code, however, nothing can be saved from the shell.

Any outputs, messages, or errors are also displayed here.

Want to give it a spin?

Type in the following and then hit enter:2+2 or print(‘Hello’).

The editor window

Since the shell can’t actually save code, the editor window is where most work is actually done. It’s pretty much just like any other text editor but with a few extra tools built-in that help you write code and troubleshoot any errors.

To open up the editor window click on File at the top of your screen and choose New File.

An empty editor window will appear. You’ll need to save the file before you can run it by going to FileSave As.

To run your code hit F5 or RunRun Module.  Go ahead and test it out 👍

IDLE also assigns color to your code. This is a big help when you’re writing programs with longer blocks of text because it’s easier to see the structure of your code and identify any mistakes.

Choosing the best IDE: IDLE vs Anaconda vs others

As mentioned, IDLE is a type of IDE.

IDEs are a coding tool that allow you to easily write, test, and debug your code.

While you technically can write code in anything that lets you write letters and numbers on a computer such as Word, Notes, Notepad or another text editor, IDEs take the code you’ve written and let you run it from within the IDE interface itself. This means you can check that everything is working right away, without installing additional software or opening any extra programs.

IDEs also tend to come with a number of other tools that make coding more comfortable (and fun) such as code completion, debugging, and resource management.

So, obviously, IDEs all the way. But which one is the best?

Turns out, there are a lot of IDEs out there and a quick Google search will yield pages upon pages of results discussing lots of opinions about which IDE is best.

IMO there are two must-have IDEs for someone looking to a) learn Python today and b) become a machine learning superstar: IDLE and Anaconda.

IDLE is great for getting started with Python quickly. It’s fast and lightweight which means you can open it and begin playing around without wasting time waiting around for a program to launch. It just feels lighter.

IDLE is great when working through introductory Python tutorials or when you’re working on a smaller-scale Python specific project. There are other IDEs out there that have great interfaces and all the bells and whistles which you probably don’t need, and almost definitely won’t use, as a beginner.

If, however, you’re planning to do any kind of machine learning or data science with Python in the future, then Anaconda is probably the way to go for the long-haul.

Anaconda provides an open source distribution of Python and comes with 250+ of the most popular Python data science packages pre-loaded. This means that with a single download and quick install you’ll have all of the major tools ready to go. And for the most part they just work out of the box. This is a really big deal when future-you is trying to get things done.

Alternatively, you can also just install Python and then individually install all of the required packages using something called PIP, but this is time consuming and finicky. Installing with PIP can lead you down a rabbit hole which could have been simply avoided if you’d just installed Anaconda in the first place.

Anaconda’s default IDE is called Spyder.

Spyder not only integrates all of the libraries essential for machine learning, but it was built specifically for data science.

It’s quick and easy to pick up and includes features like syntax highlighting, code completion, and a well designed variable explorer. Plus, Spyder’s interface is similar to RStudio which is a bonus if you plan to learn the programming language R in the future (which you should!)

Learn how to install Anaconda here.