Python Programming

The Anaconda Python Distribution

Python beginners are recommended to "install Anaconda" opposed to "installing Python".

What is Anaconda and what is the difference? Anaconda is a Python distribution. The Anaconda Python distribution contains the core Python programming language and its inbuilt modules, the Spyder and JupyterLab Integrating Development Environments (IDEs), and the most common libraries or modules for data science such as numpy, scipy, pandas, matplotlib and seaborn as well as a multitude of others. I have put together detailed installation guides for the Anaconda Python Distribution for both Windows 10 and Linux.

Why have a Python distribution? Anaconda performs a number of checks for incompatibilities when the user attempts to install additional Python modules. Such compatibilities arise when one module is dependent on another. The seaborn library for example is used for data visualization. Under the hood it uses the matplotlib plotting library. matplotlib itself is dependent on numpy which is used for array manipulation and will only install if a specific version of numpy is installed. When the user blindly installs the latest version of Python and then numpy and then matplotlib and then seaborn incompatibilities are very likely to arise. If an underlying object in numpy is changed or deprecated, this can break the functionality of matplotlib which can in turn break the functionality of seaborn and so on and so forth. This can lead to endless frustrations particularly for a new user who doesn't yet know what they are doing. Such frustrations are alleviated to a great extent by use of Anaconda.

IDEs can be thought as programs for working with Python code, similar to how one might use Libre Office or Microsoft Word to work with a document. The installation instructions in the written guides above include an introduction to the Spyder 5 and JupyterLab IDEs as well as additional instructions for maintaining a conda environment.

Python Procedural Programming

This guide is a beginner guide and will look at the inbuilt Python programming language and the concept of basic procedural programming. Procedural programming takes place line by line in the order specified for example within a script file. This guide will use the Scientific PYthon Development EnviRonment (Spyder 5) which is one of the best Integrated Development Environments (IDEs) particularly for beginners due to its simple but powerful user interface and versatile variable explorer. 

Python Code Blocks and Debugging

So far we have only looked at procedural programming where we executed every line, line by lines. It is now worthwhile understanding the concept of code blocks. The Spyder 5 Debugger is used in this guide to visualize how these code blocks operate. if, elif, else code blocks can be used to execute code dependant on a condition. A for loop code block can be used to repeat a block of code over an iterable object and a while loop can be used to repeat code while a condition is satisfied. Functions can be used to partmentalize code, particularly code that is going to be used several times. We also discuss how functions have their own local environment (namespace). Finally we end up discussing the try, except, except, finally code blocks which are used for error handling.

Python Object Orientated Programming

Python is an Object Orientated Programming Language. It is recommended early on to explore the concept of object orientated programming, particularly how one can use objects from inbuilt classes and import objects from inbuilt and standard Python modules and libraries.

formatted strings (fstrings)

Now that you understand procedural programming and the basic inbuilt datatypes. It is a good time to have a look at formatted strings which allow one to display a variable as part of a str when using the print statement.

It is worthwhile taking the time to understand the format specification options that can be used in order to print your variables in the format desired.

Data Science Libraries

The Numeric Python (numpy) Library

The numeric python library abbreviated numpy is the most commonly used python library. It is used for array manipulation.

Additional notes are available as JupyterLab Notebooks. Use the NBViewer link to view as a web page and the JupyterLab link to open within JupyterLab:


The Python and Data Analysis (pandas) Library

The python and data analysis library abbreviated pandas is one of the most commonly used libraries in data science. This library allows for dataframe or spreadsheet manipulation or in other words is in essence the Excel of python.

Additional notes are available as JupyterLab Notebooks. Use the NBViewer link to view as a web page and the JupyterLab link to open within JupyterLab:


The Python Plotting (matplotlib) Library

The matplotlib library is the python plotting and data visualization and is highly based on matlab/octave.

Additional notes are available as JupyterLab Notebooks. Use the NBViewer link to view as a web page and the JupyterLab link to open within JupyterLab:


Machine Learning

The SciKit Learn Library (sklearn)

The sklearn library can be used for machine learning applications. I demonstrate some of the fundamentals of machine learning using the standard example datasets.


General User Interface (GUI)

The Python Quasar toolkit 5 (PyQt5)

The Python Quasar toolkit 5 library abbreviated as PyQt5 is used to create an interactive General User Interface (GUI). In this guide I reinforce the basics behind object orientated programming and then look at creating some basic GUIs.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.