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.
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.
Overview of the bookWe 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.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.5 Solution to top-level challenge
3 Imperative Programming
3.1 Blocks of Code
3.3 Error handling
3.5 The Halting problem
3.6 Iterating through data structures
3.7 The guessing game
3.9 Solution to Challenges
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.7 Solution to recursion challenge
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.5 Solution to oop challenge
6 Functional Programming
6.1 Higher order functions and comprehension
6.3 The sieve of Erathostenes
6.4 Python in Python
6.6 Solution to challenge
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.5 Solutions to Challenges
InstructorsCourse 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.
ErrataAll known errata are listed here. Please contact the author if you spot any further issues
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.
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