Python in education

Benefits for LWN subscribers The primary benefit from subscribing to LWN is helping to keep us publishing, but, beyond that, subscribers get immediate access to all site content and access to a number of extra site features. Please sign up today!

In a keynote on day four of EuroPython 2015 in Bilbao, Spain, Carrie Anne Philbin looked at using Python in computer education for children. She covered some of the background on a new curriculum that has been established in England and on why Python fits well into that curriculum. She also talked about using the Raspberry Pi as a platform for that teaching and at some of the challenges in using Python in the classroom.

Philbin considers herself an educator foremost and was a teacher at the time she started out working with the Raspberry Pi and Python. She now works for the Raspberry Pi Foundation, which is a registered educational charity. All of the profits from selling Raspberry Pi hardware go to the foundation, which was set up to advance the education of adults and children in computers and computer science.

Her journey

Her journey started in the classroom where she was teaching an "information and communications technology" (ICT) class. In 2010 or 2011, Google's Eric Schmidt had made a speech in the UK (her home) where he said that UK computer science education was really bad and that it was being taught the wrong way. That was picked up by the media and was turned into a statement that all of the ICT teachers in the UK were terrible.

That was depressing to her, so she started thinking about ways to bring some of the new thinking about computer education into her classroom. She heard about the Raspberry Pi and tried to get one on the first day it was out, which was unsuccessful for her as it was for many. She did eventually get one two months later, plugged it in, and saw that it was simply a Linux computer, which was not anything new or exciting to her.

But she still saw it as a tool for teaching about computers, so to try to find ways to use it in her classroom, she decided to attend a nearby Raspberry Jam that was being held at the Mozilla Space in London. It was attended by fifty men and three women; all of the women were teachers. There were lots of "geeky projects" that were presented at the meeting, but she didn't see anything that she could bring into her classroom.

She eventually had the opportunity to address the meeting, so she explained that she was a teacher and that she wanted to bring the Pi into the classroom. The projects she saw might not inspire students, she said, and in particular might not inspire girls. That elicited a heckling response from one attendee who suggested that maybe she would need to program the device to go shopping or organize sleepovers in order to attract girls.

That was a "terrible experience" (also recounted here), but once she returned to her seat "something really amazing happened". Ten different people came up to her and told her to ignore the heckler, that they had ideas for projects that would inspire students both male and female, and that they wanted to help. From there, everything started to snowball. She "kind of just took over" the education track at the next PyCon UK and she now serves on the board of the Python Software Foundation.

In September 2014, a new computing curriculum for England was announced. From the age of five, children will learn to program and from eleven, they will learn at least two programming languages, at least one of them text-based. Unfortunately, the government only put an additional £3.5 million toward the effort, which works out to about £175 per school. That is not really a useful amount of money for training and the like.

England is something of a pioneer in requiring computer education. Israel has long had computers as part of its curriculum. Estonia, Australia, and New Zealand have recently added the subject. Some Scandinavian countries look like they may doing so in the near future. That's it, she said.

Why teach computing?

Philbin asked, why teach computing? There are a number of reasons to do so. To start with, children are creative and imaginative; they are also not afraid of failure. Educators actually train that out of them along the way. Children will also tinker with things, which is how we all learn.

Another reason is for social mobility. Most people with jobs in computer science have come from affluent backgrounds. Programming is also empowering. It makes people feel good about themselves and what they can accomplish. Bringing more diversity into the technical fields is also a reason for teaching about computers. Only 16% of IT workers in the UK (and 20% in the US) are women. Those who are creating technology are not representative of those who are using it.

The final and most important reason is shown in a video called "Humans Need Not Apply". Many things will become automated over time, including tasks for people like supermarket clerks or baristas. In addition, technology such as self-driving vehicles has the potential to put a lot of people out of a job, including taxi and lorry (truck) drivers, when it becomes legal. So the goal is to train today's children to be able to program or fix these machines.

But the focus is shifting from "why?" to "how?". The visual programming language Scratch is an easy win for young children, but eleven-year-olds need to learn a text-based language. So people started having a look at Python, she said.

Why Python?

There are good reasons to look at Python for education. It is used all over the world and is powerful enough to be used for real development. It is actually used in the real world by organizations like NASA, for example. It has a simple syntax; by comparison, writing "hello world" in Java takes six lines of code.

Probably the most important reason for educators, though, is the community. Python has a strong and helpful community. Raspberry Pi has a great community, too, she said, but Python's tops it. It is not just national and international communities that are the big draw; it is the local communities that really make Python special.

Python conferences have also taken up the cause of using the language in education. PyCon UK has had an educational track for the last eight years. This year, there were 40 teachers at PyCon UK. If you build it, they will start to come along, she said.

PyCon 2015 in Montréal had an educational track. There is an educational summit at this year's EuroPython; she was headed to PyCon Australia soon, which will also have an educational track. She suggested that conferences should try to help teachers by starting these tracks. They may not come the first year, which would be sad, but they will see and start coming.

Barriers

There are some significant barriers to students trying to learn Python, however. To start with, it is a struggle to move from Scratch to Python. The Raspberry Pi Foundation is trying to overcome some of that difficulty with a game called Pyland. Python 2 versus Python 3 is also a problem, but it really shouldn't be. There is no reason not to just teach Python 3. All of the foundation's resources are written in Python 3 and most major libraries are available for that version.

There are a number of naming issues that make Python difficult for children, she said. People write libraries for themselves and are not always consistent with the names they choose. She mentioned the general-purpose I/O (GPIO) library for Raspberry Pi as an example. It was written by a UK brewer to regulate the temperature in his brewery. That library is now used in education all over the world. Like other Python libraries, it has inconsistencies that make it hard for students.

Another problem stems from children saving their program with the same name as the library they are using. It may seem obvious to everyone in the room that naming your program that uses the pycamera library pycamera.py will not lead to happiness, but she has done it herself. When she did, there were five Python developers trying to help her figure out the problem and it actually took some time to do so.

Another example is the module for Minecraft. It is a real hook for children; it "kind of blows their mind" that you can build things in Minecraft by writing a program. But even the first line of a program causes problems:

from mcpi.minecraft import Minecraft

setPos()

mc_teleport

The capital letter often trips them up and children are impatient. In addition, thefunction's name is not all that helpful. In Ruby, for example, the function is called, which is much more obvious.

Another snippet of Minecraft code shows additional problems:

glass = block.GLASS.id mc.setBlock(40, 50, 60, glass)

mc_set_block :glass, 40, 50, 60

That is long-winded, and has the capital letters to deal with. By contrast, in Ruby it is simpler:"Please think about children when naming things", Philbin said.

Pygame is a great library for children, but it is difficult to use in the classroom. There are a lot of concepts that need to be explained before you can start doing anything with it. That makes it hard to teach in an hour-long class. Daniel Pope came up with Pygame Zero to help bridge that gap. It simplifies Pygame by providing a runtime so that students don't need to understand game loops, event queues, and other concepts right away. That means a simple program that actually does something can be taught in a bite-sized lesson. It does make some decisions for you, she said, but you shouldn't be afraid to do that for children.

Adding extra libraries is another hurdle. It is easy to do it on one computer, but not for 30 or 50—or for Raspberry Pi devices. For one thing, school computers tend to be behind firewalls or filtering software that can make it difficult to simply access the extra libraries. She and Pope have been discussing an "education bundle" that would gather up useful libraries (e.g. Pygame Zero, NumPy) into a single package to help with that problem.

IDEs

Finally, there is the problem of a Python integrated development environment (IDE) for children. Finding programming interfaces for children is difficult. She asked how many in the audience used the Python-included IDLE as their IDE and got two or three hands out of more than 500. Being bundled with Python is a big advantage for IDLE, since it will always be available, whether there is internet connectivity or not.

She noted that her school was not able to upgrade to the newest version of Scratch because you needed to sign up online to get it. At her school, the internet was slow and firewalled. There are lots of online resources and IDEs for Python, but those won't work for children and schools that don't have access (or have restricted access) to the internet.

One offline option is the PyCharm Educational Edition, which is free and open, but it is not obvious how to use it. It is great for children sixteen or older, but won't work for those who are younger. There are too many buttons and too much setup required. There needs to be an simpler open solution.

IDLE is one option. It does come with simple syntax highlighting and some auto-indentation. But it runs in two separate windows, which is confusing. Adding a Minecraft window just makes that worse. In addition, the error reporting in IDLE is "atrocious", she said.

She showed a picture of the interface for an educational program developed by Dr. Sam Aaron called Sonic Pi. It is a synthesizer that can be live-coded to create various kinds of sounds and music. She apologized because it is written in Ruby, but it is a good example of a nice interface for students.

In Sonic Pi there is a button for "Run" and one for "Stop". There is a way to make the text smaller and larger (which is needed in IDLE). It has line numbers and its windows are all together as panes in a larger window. There is an inbuilt tutorial and it has a button to align the Ruby code. She wondered why there can't be something like that for Python.

Helping out

There are plenty of ways for those interested to help, Philbin said. Meeting with educators, talking with them, and listening to their problems is one way. Adding education tracks to conferences is another. Having a special education session at a local user group would be helpful, as would mentoring a teacher so they have someone to turn to with questions. In addition, creating and contributing "awesome libraries" (which have a consistent API) would be quite helpful.

There is a new Python education workgroup that is getting started. The intent is to "make some things happen", like making IDLE better, for example. The group needs any help people can bring to its mailing list. She would like to see the group set some specific goals before she tries to get recognition from the PSF board.

Ever the teacher, Philbin gave out some homework at the end of her talk. First was to join the workgroup mailing list. Second was to read and contribute to Al Sweigart's IDLE Reimagined project. Last was to read Nicholas Tollervey's Python in Education book, which is available as a free ebook. All of the homework is due by EuroPython 2016 (which will also be held in Bilbao). "I will be checking", she said with a laugh.

There is a danger that writing code will become an educational fad and that visual programming (with languages like Scratch) will dominate. "Please help make sure that doesn't happen". She firmly believes that code should be part of the curriculum and that it should be done with Python. If that doesn't happen, JavaScript could take over instead.

Computer education could change society in a positive way, she said. When the Raspberry Pi generation grows up in 20 years, they will not all be developers, certainly. But they could all benefit from the problem-solving skills that learning programming will provide.