Okay, having decided to learn/teach Python to my 4th grade son, the first thing I need is some sort of introductory curriculum to get us off the ground. It should be designed for a young learner. Some people might just go straight for the software and begin hacking away to see what they can figure out. That approach might work for some but it doesn’t work for me. Plus, I really want to start at the very beginning and take it step by step so I can understand how I might teach similar content to statistics students.
I found what appears to be a great book for the task (i.e., teaching my son rather than my college stats students). It’s called Python for Kids: A Playful Introduction to Programming. I skimmed through the table of contents and like what I see. I suppose part of these blog posts will be a review of this book and other learning materials I dig up along the way.
So the first chapter keeps it very simple and adheres to the time honored tradition of starting with a Hello World Program. This involves two key steps: (1) getting your development environment set up and (2) writing the necessary code to output “Hello, World” onto the computer screen.
In the book, step 1 involves downloading and installing the latest version from the main website, python.org. I did this on my PC and it worked fine – seems to be some decision about version 2 or 3 that I didn’t bother to explore in depth at this stage. But, because we have iPads, Chromebooks and Android devices I thought I’d check to see if a cloud service might make life a bit easier. I found what appears to be the perfect ticket: pythonanywhere.com! It’s a freemium model. You can create a free account and there are options to upgrade to a paid account as you progress. The first step up to a “Hacker” account is only $5/month and after that the “Web Dev” account is only $12/month so it’s not terribly expensive and they take care of data backup, hosting, etc. In addition, there are collaboration tools that could be really cool; but I will reserve judgement on how cool until I’ve explored in more depth.
Hello World Program
Step 2 shows just how simple Python makes programming. Launch a “console” and type the following syntax.
That’s all there is to it!
You can just type this on the command line to see the output. We also saved this simple one-line program to a file and then launched to see it write “Hello, World”. You have to save the file with a .py extension. I couldn’t figure out how to launch the program file from the command line but pythonanywhere.com provides a UI to “Save and Run”. After writing code in different languages requiring all sorts of declarative pre-amble it was nice to save a program file with exactly one line of code.
Boom. We’re in business.
Click below to watch a video demonstrating the two steps above. I’m still working on my on-air radio personality so please forgive a few audio faux pas.