Python0: Introduction to Python Programming

Contents

1. Introduction

This website is an open educational resource to help researchers learn to program using the Python programming language. It is maintained by Andy Turner and is based on learning resources developed for GEOG5990, GEOG5991 and GEOG5995 modules taught at The University of Leeds (the old course materials may still be available via: https://www.geog.leeds.ac.uk/courses/computing/).

The website is generated by some bespoke Java code which generates a site based on standard HTML, CSS and JavaScript. Please raise issues/submit pull requests via the agdturner-github-io GitHub repository (which contains the generated output) and/or the agdturner-github-io-generator GitHub repository (the Java that generates the website content) to help.

Each page in the site has a button at the top to change between a lighter and darker page style, then a navigation section that links to the other pages. The pages are sequential and also link to the next page after the pages main content.

The Index page is a glossary of terms that links back to page sections where terms are used.

The References page is a useful list of references and links to other resources.

Pages with multiple sections have a contents towards the top that links to those sections.

To get the most from the learning resources, work your way through the pages and undertake practical exercises as directed.

2. Syllabus

General computer programming language concepts, including:

Version Control.

Python language development and limitations.

The Python Read Evaluate Print Loop (REPL) environment.

Running Python programs via the command line.

Using Jupyter Notebook.

Using IDLE and Spyder.

Python containers including; lists, tuples and dictionaries.

Python docstring syntax.

Python program input and output.

Structuring and organising Python code into Classes, Modules, and Packages.

Python environment management using Conda and venv.

Using the Python 3 Library.

Using third party packages available via the Python Package Index.

3. Expectations

You will learn about:

Computer programming mostly involves computational thinking, planning, problem solving and testing. It is often helpful to break a task into smaller subtasks, and gradually develop an implementation. Often good solutions to coding tasks involve doing things repeatedly for a given sequence of things.

If you are new to computer programming, there is quite a lot of terminology to get used to, some is generic to programming, some is specific to Python.

There are some key concepts which may take a few attempts to get used to and comprehensively understand.

4. The Learning Journey

Develop your understanding through practise and by reading.

Be experimental - test your understanding by testing things do what you expect. If things do not do what you expect, try to understand why. Encountering an exception error fault or failure is a learning opportunity that should not be ignored!

A key to coding is learning to be able to interpret error messages and understand why they occur. If a program unexpectedly raises an exception, then try to diagnose why this occurred. Ignoring error messages is nearly always a mistake!

Be cautious and only run code you trust.

The webpages with names starting 'ABM' are a sequence of practicals that progress the development of a basic spatial Agent Based Model. The ABM is a simple digital simulation model of semi-autonomous spatial entities that move in an environment, interacting with the environment and each other.

Developing the ABM by following instructions puts into practise some of the theory encountered. By the end of the practicals, you should have ABM model code that has a basic GUI, reads in data from local files and from the Web, and produces an animation, data files and user friendly messages.

The aim is that after completing the last ABM practical, you will have sufficient knowledge and skill to develop the model in interesting ways without being given detailed instructions.

Do not expect to master python by the end of this course. Usually this takes many thousands of hours of practice over several years.

Try to enjoy the learning journey, the challenges and the rewards. Learning to program and learning Python is empowering!

5. Platform/Software

All the software used in this course is Free and Open Source Software (FOSS) - available to download and install on Linux, Microsoft Windows, and MacOS.

Date last modified: 2024-01-03

CC0 Licence