Conceptual Programming with Python

Thorsten and Isaac have written this book based on a programming course we teach for Master’s Students at the School of Computer Science of the University of Nottingham. The book is intended for students with little or no background in programming coming from different backgrounds educationally as well as culturally. It is not mainly a Python course but we use Python as a vehicle to teach basic programming concepts. Hence, the words conceptual programming in the title.


We cover basic concepts about data structures, imperative programming, recursion and backtracking, object-oriented programming, functional programming, game development and some basics of data science.

View a sample »

The Book

1st Edition Thorsten Altenkirch and Isaac Triguero, University of Nottingham.
Self-published on,
30th September 2019,
Paperback: ISBN 978-0-244-82276-7;
250 pages

Buy »

About us

Thorsten Altenkirch (also known as Der Chef) and Isaac Triguero (also known as El Jefe) are with the School of Computer Science of the University of Nottingham.

More »

Overview of the book

We start with an exploration of Python from the top-level (Chapter 2), which covers some basic concepts like data types, coercions, functions and so on. We also introduce a graphical view of data structures in Python. Next we look at imperative programming (Chapter 3) which is the traditional way of programming present in Fortran or C. We introduce basic control structures like if-then-else and loops. We also discuss Turing's famous Halting problem. After this, we introduce one of the most powerful spells the young software wizard should master: recursion (Chapter 4), that is a function that calls itself. We are also using this to implement a sudoku solver via backtracking. Obviously, we cover Object Oriented Programming (Chapter 5) which is now a standard approach to program development. We also explain the use of trees to represent expressions and knowledge bases. An alternative to Object Oriented Programming is Functional Programming (Chapter 6), which is close to a mathematical understanding of programming. We also cover infinite data structures and how to write a Python interpreter in a functional style. Now you need to develop a bigger program, ideally in a group, and we suggest to write a game because it is fun and it is easy to understand what the goal is, hence we introduce the pygame library (Chapter 7). Finally, we give an introduction to Data Science which underlies the modern approach to Machine Learning (Chapter 8).

We present some challenges during the text, which you should try to solve yourself, but our solution is provided at the end of the chapter. Each chapter finishes with a quiz and exercises. The quiz can be easily done by using the Python interpreter but the point is to see whether you understand the language well enough to execute programs in your head. Indeed, the ability to run programs in your head is essential if you want to be able to write programs. The exercises are of different degrees of difficulty.


1  Introduction
 1.1  Why Python?
 1.2  How to use Python?
 1.3  Where to find more information?
 1.4  Overview over the book
 1.5  About the authors
2  Python from the top-level
 2.1  Basic types and operations
 2.2  Data structures
 2.3  Mysteries of Python
 2.4  Summary
 2.5  Solution to top-level challenge
 2.6  Quiz
 2.7  Exercises
3  Imperative Programming
 3.1  Blocks of Code
 3.2  Inputs/Outputs
 3.3  Error handling
 3.4  Loops
 3.5  The Halting problem
 3.6   Iterating through data structures
 3.7   The guessing game
 3.8  Summary
 3.9  Solution to Challenges
 3.10  Quizzes
 3.11  Exercises
4  Recursion and backtracking
 4.1  Prelude: functions calling functions
 4.2  The Towers of Hanoi
 4.3  How is recursion executed?
 4.4  Some combinatorics
 4.5  Solving sudoku: Using backtracking
 4.6  Summary
 4.7  Solution to recursion challenge
 4.8  Quizzes
 4.9  Exercises
5  Object Oriented Programming
 5.1  First example: a class to handle accounts
 5.2  OOP example 1: Implementing Expressions
 5.3  OOP example 2: Creating a Knowledge Base
 5.4  Summary
 5.5  Solution to oop challenge
 5.6  Quizzes
 5.7  Exercises
6  Functional Programming
 6.1  Higher order functions and comprehension
 6.2  Laziness
 6.3  The sieve of Erathostenes
 6.4  Python in Python
 6.5  Summary
 6.6  Solution to challenge
 6.7  Quizzes
 6.8  Exercises
7  Implementing games with pygame
 7.1  What is Pygame?
 7.2  The Pong Game
 7.3  Software Engineering
8  Getting started with Data Science
 8.1  Data analysis with the Pandas library
 8.2  Visualising your data
 8.3  Mining the data
 8.4  Summary
 8.5  Solutions to Challenges
 8.6  Exercises


Course instructors can request an inspection copy of the book, together with a large collection of introductory and advanced exams and answers based on the content.


All known errata are listed here. Please contact the author if you spot any further issues

About us

Thorsten is from Berlin, Germany and has grown up on the western side of the wall. Indeed it is a little known fact that the wall was only built for him and it was taken down 6 weeks after he left to start his PhD in Edinburgh, Scotland. Having worked as a programmer in Berlin for various companies, Thorsten got sucked into more theoretical realms doing a PhD on Type Theory which is a synthesis of logical reasoning and functional programming. Following this ambition he has been working in Gothenburg, Sweden and even in (for a Prussian from Berlin) more exotic places like Munich in catholic Bavaria. Eventually at the turn of the Millenium, Thorsten joined the School for Computer Science at the University of Nottingham where he founded the Functional Programming Laboratory together with his colleague Graham Hutton (check out Graham's Haskell book!). He ended up teaching Python after a sabbatical at the Institute for Advanced Study in Princeton which left him no other choice after his return. However, he has been enjoying teaching this course, especially since he was joined by his colleague Isaac.

Isaac was born and bred in a small town, called Atarfe, in the region of the magnificent Granada, Spain, where the emblematic Arabic palace and fortress 'Alhambra' sits. Unfortunately, he can't tell the Alhambra was built for him -- and luckily it was not demolished after his departure --, but he can undoubtedly say that it is way more beautiful than that Wall from Germany. Isaac studied his MSc and PhD degrees in Computer Science at the University of Granada, where he was drawn into all the buzz words of the moment (Data science and Big data) before departing to Ghent where he worked (and mostly ate waffles on a daily basis) as a postdoctoral researcher. A few years ago, Isaac joined the School of Computer Science at the University of Nottingham, and he was soon severely punished and trapped into teaching this programming course with the inimitable Thorsten. As a ''junior'' professor, working with the old and wise Der Chef and his bold teaching style has been a real challenge for him, but it turned to be a very rewarding experience, in which they ended up teaching each other quite a few things.

Thorsten and Isaac have mostly written this book together, but they led different chapters; you are challenged to guess who wrote what...

Contact us: Isaac, Thorsten