William Matthews


Getting Started With Python: For Windows Users

So you want to be a programmer?

That’s awesome! This guide will help you with (maybe your first programming language,) Python.

To do this you will need a few tools, and you may feel like you’re being plunged in the deep end at times, but worry not - this is what I believe is the best way to learn and become a skilled programmer.

What is Python?

Python is extremely accessible if you haven’t done programming before! Its syntax is very simple, error messages are helpful, there’s fantastic documentation and best of all - it’s open source! Python is completely free to download! There also exist a multitude of modules that can be downloaded (for free) to do other more complicated things.

Python is also a scripting language - which means that you don’t have to fiddle around with compiling code! This aids in speeding up prototyping and allows you to not have to worry about compilers, so generally a good point to start from.

Python is an interpreted language, what this means is there exists a bit of code (called the interpreter) which goes through your program (written as text), reads the line of code, and executes what you intend it to do. This line-by-line reading that the Python interpreter does means code errors will only be found when the interpreter reads bad code, so it is best to have a editing platform that highlights errors for the aspiring programmer.

What can you do with Python?

Technically anything that is computable can be achieved with Python as it is Turing complete! But some good examples of things that can be done with Python easily (and I do mean easily) are:

  • File manipulation
  • API interaction (Twitter, CERN etc)
  • Machine Learning
  • Machine Vision
  • Web back-ends (and even hosting)
  • Apps with a user interface

And much more of course!

OK I get it! Python is cool - can I start using it now?

Sure, but first you need to install a few things before we progress to your first “Hello World!” program.

Your text editor - where you will do your programming

First, we need a text editor. If you are a psychopath you can just use Notepad, but a good (free) piece of software to use is the Atom Editor.

Click on the link above to download Atom (an Electron app), and install it.

Atom is a pretty nifty bit of software - you can install plugins to do all sorts of crazy stuff. A fairly vanilla and useful plugin to immediately get to see what I mean is ‘MiniMap’.

Other useful plugins I recommend starting with are: - Highlight Selected - Pigments - Linter (requires some extra setup - you may need to come back for this one)

But honestly it’s all down to you what you do with your editor - make it your own!

Your version of Python

You may be scratching your head somewhat at the many versions of Python to download on Python.org. I recommend firstly that you go for Python 3 - as it is most commonly used and offers significant performance improvements. It’s quite irritating when it comes to sub-versions (why oh why does Python have to be updated so much I do not know why), but I personally recommend grabbing Python 3.7.4 as it has generally great module support while still being very up to date.

Download Python 3.7.4 and install it, making sure to add Python to the PATH!

Your shell

For your shell I am going to suggest you use Powershell. You already have this installed! You can open Powershell by pressing the Windows Key and searching for Powershell. Open it up to see what I mean - it should be a blue terminal. List the files in your current directory with the command ls for your first Powershell command.

To get around directories, you can use the cd command, this command *c*hanges *d*irectory. To use it, I will assume that when I enter ls I see a ‘Documents’ folder, to go to documents, do cd Documents.

You even have auto-completion in Powershell (how fancy!), to use it for the above example, type cd Do and then press the Tab key, and it should fill in the rest of the command.

To go ‘up’ a directory, do cd ...

Python Package Installer

So now I’ve made you grope around in Powershell a bit, I’m going to help you install your first Python module!

You may have to ensure that your Powershell is in administrator mode for installing modules.

So - first we have to update our Python package manager (called pip).

Since we have Python 3, we enter in Powershell: python3 -m pip install --upgrade pip. In your system, it may work differently and you may have to omit the ‘3’ (so it would be python -m pip install --upgrade pip).

Wicked, so now that is upgraded, let’s install a module. I’m going to use ‘NumPy’ as our first module to install, this gives us access to some fairly incredible numerical methods that you may very well end up using a lot (I certainly do). To install NumPy, do pip install numpy in your Powershell. You may have to use pip3 instead of pip, but this depends on your system.

If something has gone horrifically wrong here - you can exercise another pro-programmer move, and Google the error message to see what happened and how to fix it!

Hello World

The Interpreter way

So now everything is set up, let’s go and talk to the interpreter. In your Powershell window, enter python3 (or python - depending on your system) and a Python shell should appear.

To do your first-ever “Hello World”, type print("Hello World!") and press Enter. Just like that - you’re a Python programmer.

Using the interpreter like this is usually useful if you want to test something quickly for sanity reasons - the code you enter is lost when you close the session so it’s best to put it in a file!

Your first .py

Open Atom, and create a new file, save it as ‘hello.py’. Now you have saved the file Atom will know you are working with a Python file, and highlight your code so it’s way more readable.

Enter the magic phrase print("Hello World!") into the file and re-save it.

Good practise dictates that you have a ‘coding’ folder setup to save this in, so your software is all in the same place!

Go to the location of the ‘hello.py’ file with Powershell (do it the hard way with ls and cd), and enter python3 hello.py (or python hello.py you get the gist).

You should then be presented with “Hello World!” in your shell if everything worked to plan.

The real journey begins

This is basically where you can start to spread your wings and fly as a programmer - the nasty awful bit is covered (nobody ever wants to explain this bit), and much better resources exist to help you here on your journey to becoming a programmer.

I recommend you start with either the well-made tool by JobTensor or through LearnPython.org. These guides are a fantastic way to learn Python and helped me get to where I am.

From there, download some data-sets! Play with data, learn, grow, plot, experiment, become a master of Python.

If you want more in-depth tutorials please let me know via the E-Mail link, and I’d be happy to have a go at topics that are in demand! :)