Learn to program‎ > ‎

Learn to program with Python

Now that you've learnt what algorithms are, how to represent them, and a little about the Python programming environment, it's time to learn a little more about Python. There are plenty of free courses, resources and books out there, so there are no excuses. There is also plenty of opportunity to program in the courses on The Computing Café but you will still need to do a lot of work on your own.



Install Python 3, useful libraries and tools Get Ready

Standard Python

Install Python 3

Grab Python from the Python website (use version 3.5 for increased compatibility)

When you are installing Python, make sure that you opt to add Python to the 'path'. After Python has installed, make sure it works by starting up IDLE (the built in development environment) from the start menu - you might not know what to do yet, all will be revealed later! To install the rest of the useful packages, you need to use a 'command window' which you can start by typing 'cmd' in the 'Search programs and files' box on the Windows start menu. Type 'cd c:\' and press the  ENTER  key on your keyboard before you perform the next steps.

Install the Numpy library

First, install Numpy by typing 'pip install numpy' at the command prompt and pressing  ENTER . Python should finish with 'Successfully installed numpy-x.x.x'. Test your Numpy installation in IDLE ...

>>> import numpy
>>> numpy.version.version

Install the SciPy libary

Next, install SciPy by typing 'pip install scipy' at the command prompt and pressing  ENTER . Python should finish with 'Successfully installed scipy-x.x.x'. Test your SciPy installation in IDLE ...

>>> import scipy
>>> scipy.version.version

Install the PyQT binding

It seems that you have to download the correct PyQT4 bindings and can't install them directly using 'pip'. 

Download the PyQT4 binding for your version of Python, move the 'whl' file onto the C: drive and install it by typing 'pip install pyqt_filename' at the command prompt and pressing  ENTER . Python should finish with 'Successfully installed PyQT4-x.x.x'. Unfortunately, this version of PyQT does not seem to install start menu shortcuts but you can find shortcuts to the two application you need in C:\Program Files\Python35\Lib\site-packages\PyQt4 - make shortcuts to 'assistant.exe' and 'designer.exe' and pop them in the Python start menu folder. Test your PyQt4 installation in IDLE ...

>>> from PyQt4.QtCore import QT_VERSION_STR
>>> QT_VERSION_STR

Install Matplotlib

Install Matplotlib by typing 'pip install matplotlib' at the command prompt and pressing the  ENTER  key. Python should finish with 'Successfully installed matplotlib-x.x.x' amongst other dependencies. Test your Matplotlib installation in IDLE ...

>>> import matplotlib
>>> matplotlib.__version__ # There are four underscores!

Install PyGame

Install PyGame by typing 'pip install pygame' at the command prompt and pressing the  ENTER  key. Python should finish with 'Successfully installed pygame-x.x.x'. Test your PyGame installation in IDLE ...

>>> import pygame
>>> pygame.version.ver

Install Notepad++

Grab and install Notepad++ from the 
Notepad++ website. Nice for syntax highlighting!

Install Thonny

Finally, even though Python comes with it's own 'development environment' called 'IDLE', it's well worth installing Thonny. From the command prompt, type 'pip install thonnyapp' and press the  ENTER  key. Python will download and install Thonny and a separate shortcut to the editor, hopefully responding with 'Successfully installed thonnyapp-x.x.x'. Since Thonny comes with it's own integrated Python interpreter, to make it work with our fully-loaded Python installation, we need to change the default interpreter from 'Tools > Options > Interpreter' and choose 'Python 3.5' from the drop down list. You should be able to successfully rerun the tests you performed earlier (or checkout all the installed packages from 'Tools > Manage Packages').

Ask your teacher then!

WinPython

Alternatively (and preferentially), you could install WinPython, a completely PORTABLE Python installation which comes in a full version with literally hundreds of libraries already installed or a 'zero' version into which you can install your own. I'm going to go for the zero version and install all the required libraries myself so I know what's there.

Download the light version of WinPython

Visit the WinPython homepage and click the 'Download' button next to the version of WinPython you wish to use (choose the 32 bit version for increased compatibility). This will take you to the Sourceforge page for WinPython - make sure you download the 32 bit 'Zero' version which will download as an 'exe' installer. Save this to your desktop or userspace.

Run the installer

Double click the installer, choose 'Run' and click through the dialogues accepting the default options. You should be left with a folder in the same location as the installer with the name WinPython-32bit-?.?.?.?Zero where the '?' will be different depending on which version you have downloaded. I have renamed the folder to 'WinPython' but you can leave it like this if you want. You can now safely delete the installer.

Customise the installation

WinPython Zero ships with shortcuts for all the tools but we can safely delete the ones we don't want. We've got enough programming environments and Spyder uses PyQT5 which doesn't work well with some of the GUI development tools we use. Open up the WinPython folder and delete ...
  • Spyder reset
  • Spyder
You should be left with ...
  • IDLEX (Python GUI)
  • IPython Qt Console
  • Jupyter Lab
  • Jupyter Notebook
  • Qt Designer
  • WinPython Command Prompt
  • WinPython Control Panel
  • WinPython Interpreter
  • WinPython Powershell Prompt

Install Numpy

Open up the 'WinPython Command Prompt' and type 'pip install numpy' and pressing the  ENTER  key. Wait for the installation to complete and then test your numpy installation in IDLEX by typing ...

>>> import numpy
>>> numpy.version.version

Install SciPy

Back in the 'WinPython Command Prompt', type 'pip install scipy' and press the  ENTER  key. Wait for the installation to complete the then test the installation by typing the following in IDLEX ...

>>> import scipy
>>> scipy.version.version

Install PyQT4

Download the PyQT4 binding for your version of Python, move the 'whl' file onto the 'scripts' directory in the WinPython folder and install it by typing 'pip install pyqt_filename' at the 'WinPython Command Prompt' and pressing the  ENTER  key. Wait for the installation to complete and then test your PyQT4 installation in IDLEX ...

>>> from PyQt4.QtCore import QT_VERSION_STR
>>> QT_VERSION_STR

Install Matplotlib

Type 'pip install matplotlib' in the 'WinPython Command Prompt' window to install Matplotlib and its dependencies. Wait for the installation to complete and then test your Matplotlib installation in IDLEX ...

>>> import matplotlib
>>> matplotlib.__version__ # There are four underscores!

Install Pygame

Type 'pip install pygame' in the 'WinPython Command Prompt' window to install Pygame. Wait for the installation to complete and then test your Pygame installation in IDLEX ...

>>> import pygame
>>> pygame.version.ver

Install Jupyter Notebook

Type 'pip install jupyter' in the 'WinPython Command Prompt' window to install Jupyter Notebook - a beautiful interactive Python programming environment. Test your Jupyter Notebook installation by double clicking the 'Jupyter Notebook' icon in the root distribution folder. You should see a command windows open up and then a browser window with the actual notebook.

Jupyter notebook


Install Jupyter Lab

Type 'pip install jupyterlab' in the 'WinPython Command Prompt' window to install Jupyter Lab software - a more powerful (but probably less useful to us) scientific Python programming environment. Test your Jupyter Lab installation by double clicking the 'Jupyter Lab' icon in the root distribution folder. You should see a command windows open up and then a browser window with the actual lab.

Jupyter Lab


There are plenty of other useful libraries that you can install into either a standard Python Installation or into a portable WinPython installation including ...
  • easygui - Simple GUI development (pip install easygui)
  • guizero - Slightly better GUI development (pip install guizero)
  • pillow - Image / graphics manipulation library (pip install pillow)
... and I'll add to the list as I find more!

Download some free books Independence

Grab yourself some free 'books' from the World Wide Web ...

Enrol on an online course Structure

Enrol on an online course to help you learn

Watch lots of YouTube videos Structure

The list is endless, but here are a few of the best ...

PythonByteSize - over one hundred free video tutorials on Python 3 from basics to some really advanced stuff suitable for A Level and beyond. Lots of the videos are concerned with programming Graphical User Interfaces using the Python Tkinter library.


This is an embedded playlist so if you click on the ...


... icon, you can choose a different video to watch if you like.

Visit the PythonByteSize website and subscribe to the channel on YouTube.
 

Socratica - 30 or so videos which give you a quick (and humorous) introduction to Python


This is an embedded playlist so if you click on the ...


... icon, you can choose a different video to watch if you like.
 


CS Dojo - Introduction to Python programming for absolute beginners. CK uses Jupyter Notebook to teach this online course; look back to the installation instructions for WinPython which might be a little easier than installing through the Anaconda Package Manager ...


This is an embedded playlist so if you click on the ...


... icon, you can choose a different video to watch if you like.
 


Learn to Code GCSE - Brilliant series outlining all the basic and more advanced techniques used to learn to program in Python for GCSE level and beyond. There are currently four playlists to choose from ...


Beginners

This is an embedded playlist so if you click on the ...


... icon, you can choose a different video to watch if you like.
 



GCSE Level

This is an embedded playlist so if you click on the ...


... icon, you can choose a different video to watch if you like.
 



Pygame

This is an embedded playlist so if you click on the ...


... icon, you can choose a different video to watch if you like.
 



Text adventure

This is an embedded playlist so if you click on the ...


... icon, you can choose a different video to watch if you like.