Preface
Welcome to Creative Python Programming with Strype. As you can see, this is the second volume in a series of books introducing Python programming using the Strype environment.
The book sequence
Each book in the series builds on the knowledge from the previous volume, developing deeper skills and understanding as you work along. The books can be read in sequence, and you will go through a carefully thought-out path of activities and exercises to develop your programming knowledge. Or you can read them on their own – each forms its own self-contained unit. If you are entirely new to programming, you should start with Volume 1. If, however, you have some prior experience, you may well choose to jump in with a later volume. The summary below gives you an idea of the level of understanding expected for each volume.
Creative Python Programming with Strype
Volume 1 – Getting started with Python
The first volume starts at the very beginning. It does not assume that you know anything about Python, Strype, or indeed programming at all. It takes you from a fresh start to writing quite sophisticated programs.
The emphasis in this book is on creativity: We use a variety of graphical examples, such as an interactive game, to go through various open-ended projects that encourage you to bring in your own ideas and invent your own goals.
Through a series of carefully constructed activities, you learn many general and fundamental programming concepts and constructs: functions, variables, assignment, conditional statements and loops, data types, random behaviour and more. At the end of this book, you have worked with graphics and sound, and understand program structure, modularisation and good programming practice.
Volume 2 – Working with data
This second volume is the one you are looking at right now. We assume that you are somewhat comfortable with the constructs listed above in the description of the first volume, and build up your skills from there. One important aspect that is central to the material in this book is one of the most powerful aspects of computers: the ability to work with large amounts of data.
In studying this volume, you will learn to work with data sets to process and analyse them. These can be text (such as books), or sets of numbers (such as temperature data or sound samples). You will learn a lot about using lists in Python, which is one of the central constructs to work with data.
Towards the end of this volume, we also look at graphics and sound again, and we see how the representation of data can help us to build more interesting games.
Volume 3 – Structuring data
The third volume builds on this one and progresses to even more interesting projects. We learn how to use a greater variety of data structures, such as tuples and dictionaries in addition to lists, and how to combine these to model more interesting data. We do not only analyse data sources, but we also take a look at generating text, in a way a text prediction algorithm might do. In the process, we will gain a basic understanding of the inner workings of large language models (LLMs) when we write a simple version of an algorithm that is at the core of these systems.
A note for learners: How to use this book
In this book sequence, we encourage you to be creative. We would like to get you to a point where you can take control and work with problems and topics that interest you. We do not only want to teach you how to write programs, but show you why programming might be interesting for you. We hope that you will actually enjoy working through this book.
This also means that you should decide yourself how to work with this book. You can either let us guide you, read the chapters in the order in which they are presented, and we will take you through a carefully constructed sequence that gives you a full understanding of the topics. Or you might jump back and forth, look at projects that interest you, and then look back when you discover a gap in your knowledge. It’s up to you. The one important principle you should stick to, however, is this: do the programming!
You will not learn to write programs just by reading the book. Even if you think you understand something, make sure to write some code making use of it. Write programs. Lots of programs. You will only become good at programming by programming, not by reading.
Strype
We make use of the Strype environment (available at strype.org) – an online, frame-based Python development environment – for all practical exercises in this book. Strype is very tightly integrated into this text, and some projects are difficult to achieve without it.
For this volume, we assume you are familiar with editing in the Strype editor. If you are not, we recommend that you read Appendix A and B of the first volume before starting your work.
Acknowledgements
Pierre Weill-Tessier, a core member of the Strype development team jointly with the authors, has done a lot of work on the implementation of Strype. His work has contributed to many of the outstanding features of Strype and made this book possible. Pete Dring has provided feedback on an early draft of this book. His comments have helped us greatly to make improvements to the text. We wish to thank them both for helping us to write this text.