Learn to Code: Python

Python is the programming language which really inspired IrishCyborg to delve deeper into programming. After starting with JavaScript we encouraged him to look at other languages to study. There were two books which we used;  Hello World! Computer Programming for Kids and Other Beginners, Python for Kids: Teach your Kids to Code in Python. and Python for Kids: A Playful Introduction to Programming. The latter was preferred over the former but both have been good resources. One of the big draws with Python is that it has a great graphical user interface package (the bit of the programming language that can draw stuff on the screen) called TkInter.

Python in Summary

Requirements Local installation required on any modern computer.
Cost Many learning resources are free but there are also paid alternatives.
Independence Level Children can work through some material independently after the initial set up.
Target Beginner / ages 9 & up
Outcomes Write fully functional computer programs that do stuff.
Resources The two books that we used essentially cover the same topics, so only one would suffice. IrishCyborg preferred the Python for kids book for which there is an earlier version available for free download here 

Python Background

The Python programming language was created in 1991. It is named after the  Monty Python’s Flying Circus TV show, not the snake. Python is a fully formed grown up language that is widely used by many of the top companies around today. Google were so much enamoured by it that they hired the language’s creator Guido van Rossum. Not only did he invent the Python language but also is credited with the origination of the phrase Benevolent Dictator For Life for his role within the Python community.

python

Getting Started

If your child has had some background programming experience, then I would suggest that you follow a similar approach to us. Buy the Python for Kids book (or download the free earlier version), get the software installed on your computer and let them follow the book for themselves. Be prepared to help them out with explaining what is written in the book, but rest assured that it is an easy read. The ability to follow along with a book to learn a new skill is an essential life skill in itself.

If you search for “how to learn python” vs “how to learn JavaScript” you will notice that there aren’t as many resources for kids to learn Python as JavaScript. I expect this is because there is a lot more JavaScript out there than Python and that JavaScript could be considered easier to learn. Learning Python as a second or third language is a fantastic idea, the more languages that are learned the easier it becomes. If you are starting off with Python as a first language then consider some of the interactive resources I’ve listed at the end of this post, but do also consider the books as they are an excellent resource.

What is good about Python?

  • Python has a large collection of available libraries. By library I don’t mean a building with loads of books and people that say ssshhh! In computer science parlance a library is a collection of pre-written code that can be reused for specific purposes. In Python a library is also commonly called a package or module, there are differences between these terms but for the beginner they can be considered the same. As an example, if you were writing a program which required very specific numeric measurements with a high degree of accuracy then you would use the NumPy library. Using a library saves you from having to write that code capability yourself. Of course most beginners won’t need to care about having a fraction accurate to the squillionth decimal place but they may be impressed with what can be done with the “drawing-stuff-happening-on-screen” library called TkInter.
  • Another benefit with python is that it comes with an interactive console. Having this means that the student can play with code as they write, like having a scratch pad for ideas beside a typewriter. With the console you can type stuff in and see what happens. If it has the desired effect you can copy it out to a file which becomes your Python program.
  • The type system is dynamic. The type system is what defines all of the objects (variables, functions or modules) in a language. When a programming language uses dynamic typing, it will auto determine the ‘type’ for you from the context. The opposite of dynamic typing is static typing. This concept is best explained with an example; suppose I ask you if you prefer an apple or an orange?  You would know from the context that the types of object I am referring to are both fruit. You can infer the types from the context of the question by taking both possible answers into account and inferring what type of objects make them comparable. If I were to ask if you think apple makes good hardware then you know from the context that I am not referring to the fruit. Some programming languages make you define the type of a variable before using it in your program, this is a more formal way to program and is referred to as static typing. This formality can be counter-intuitive to the beginner, but there are also some very good reasons for using a static typed language. Python is one of the languages that will try to infer the type from the context, hence it is a dynamically typed language.

Our Children’s take on Python

IrishCyborg and IrishWrath are our only two Python learners. IrishWrath worked through an online course and thought it was OK, “a bit like JavaScript” in his words. IrishCyborg loved the Python for Kids book. He learned heaps from this language. When I asked what his main reasons for liking Python so much were he told me that the number of available ‘mods’ (he means modules or libraries here) and the TkInter graphics package were the main reasons why it was so appealing. As with Scratch the main draw for kids is the ability to create their own games. IrishCyborg took the code and graphics for the classic snake game from another programming book (Realm of Racket) and converted this to python code. When they are interested in something they learn it much better that when you have to drag them along kicking and screaming.

python-snake-game

Other Resources for Learning Python

LearnPython has an interactive console in your browser for you to type code into. This may not suit younger kids.

Google offer a developer’s Python Class here complete with video lectures and content to read and follow at your own pace.  It is a college lecture type format so more suited to slightly older kids.

Codecademy have a Python course available here. This has a similar look and feel to their JavaScript offering which I wrote about previously. Their approach is to nudge the reader in the right direction.

Coursera has a beginner Python course available here. The structure of Coursera makes it more suitable to teens’n’older learners.

If you are an adult wishing to learn python yourself (just so you can keep up with your children’s vocabulary) I would suggest you start with the people who maintaining the language: python.org. They have a assembled a list of beginner tutorials for you to follow at your own pace here.

Other Posts in the ‘Kids that Code’ series.

Share This

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.