intro to py5 and python#

These tutorials offer a path down a few topics of interest for a complete beginner to Python (and to py5). No external knowledge is assumed, and whenever possible, they have been written specifically so that they can be enjoyed in any order. You might find some of them much more challenging, and some extremely straightforward.

When we’re instructing a computer to run code, we cannot use regular human language. Instead, code takes the form of an algorithm or a series of algorithms which are handed to the computer. Although the word algorithm has had a lot of complex recent use, at its simplest form, an algorithm is just a set of rules or instructions for a computer to follow. Unlike most humans, if a computer is given unclear instructions, it can’t problem-solve its way out of the situation - it will simply stop in its tracks. This means that small errors in the syntax (grammatical structure) of your code will cause many of the problems you run into, and it will get easier as time goes on to anticipate and correct them.

Get familiar with the py5 reference – this will serve as your glossary for the functions, methods, and data types we discuss here. When you’re using the py5 reference pages, you should be aware of the mode and the syntax (structure of code) being used, as these may differ from what is used in this tutorial.

Firstly, we’ll often be using something called static mode, which is a simple way to get started with py5 (especially if you’re using py5bot). This mode is for making sketches which don’t move or animate; they are static in terms of their state or motion. Later, animated sketches and sketches with user interaction will split code up into blocks labeled with functions like setup() and draw(), which facilitates animation.

You’ll also notice that the reference seems to be starting a lot of functions and arguments with py5. because these functions are built into py5 itself, rather than being a feature of regular Python code. However, if you’re using the py5bot or py5 kernels, or coding using an addon like the py5 mode for the Thonny IDE, you may be able to completely omit these references to py5.