Home HTML Kodu Python Robotics Sonicpi Scratch Resources Logo About Me

Python is widely used as a first language and provides a great 'first day' experience. Much like the first page of a book students need to be 'hooked' early on to have the excitement and curiosity to persevere in the face of the inevitable frustrations of learning something new. Using Python to control an AR Drone provided an instant wow! factor. It takes only a couple of sessions to get some very satisfying results, the animation below only took 2 sessions.

We have started coding with Python this year in the P8 classes (aged 11-12) just dipping our toes in really as we've been simply been making fun patterns and animations via turtle graphics. Python is one of the easier languages to grasp and importantly there are lots of good entry level resources out there, it is one of the most widely-used and widely-taught programming languages in senior schools, universities and businesses. So far so good the classes have enjoyed the instant feedback that a few lines of code can give and the project above dovetailed nicely with our work on the Sonic Pi.

Should we be teaching Python at this age? Well I think yes and no (well not too much anyway). Python is very effective at teaching the computational thinking behind the simple programs, however his can be done very effectively using a drag and drop language such as Scratch or Blockley.

So why use Python? My main reasons for introducing Python are two fold, Python is a full and widely used programming language that at a glance quite daunting, like looking up from the base of Everest. However just spending just two or three lessons coding with Python can give children the confidence to take the next step, to open the book ,to look at the tutorial, to have a go if that's what they want to do. It also shows children how fun programming can be, that you don't have to be a genius to be a programmer, that anyone can create something beautiful with code and that there is a bridge between science technology and art.

I wouldn't encourage anyone to spend a long time on teaching Python in a primary school however dipping a toe in has had very pleasant results, a number of children have been inspired to create fun and interesting programs in their own time.

A few lines of code, that include the key computing concepts, variables and loops, can give instant results. The few lines above the code above gives us a square spiral like the one (below).

This then can be tinkered with to give more exciting results. The students enjoyed this exercise giving time to play with the code is essential, just by adding a different colour and one degree gives a dramatically different result.

The ultimate first day experience with Python had to be with the AR Drone. Using Auto flight we could control the AR.Drone 2.0 from a laptop via Python. AutoFlight is a very cool program that allows you to do that, and much more. Control it with a game-pad, set a security distance to walls, and even create 3D models of your environment. It's possible to attach additional sensors and even fully automatise the drone's behaviour with the Python scripting feature.

A few simple lines of code can command a take off hover and land.

Madlibs make for an excellent first lesson. Mad lib is a phrasal template word game where one player prompts others for a list of words to substitute for blanks in a story, before reading the often comical or nonsensical story aloud. A real world example The following code can easily be adapted by students to make their own madlibs.

When children write their own programs in Python more often than not these will contain errors or bugs and fixing these requires logical reasoning (logical errors) to explain what the program is actually doing.

Syntax errors however are a bit like spelling and grammar, they are important, however at a primary school age, I feel its important not to get bogged down dealing with the many syntax errors that can occur when learning to code, but simply to be aware of these and to explore simple strategies on how to debug e.g. using find and replace if the same error has appreared more than once.