Python: A Perfect Teaching Aid for Youngster in CoderDojo Indonesia


CoderDojo logo

 

Part of my life mission is to teach others what I am good at. This include capoeira and coding. While the first thing is not suited to this blog, but the later is. And to try spreading coding as a cool hobby, I targeted youngsters/children around my neighbourhood. For this, I highly motivated by CoderDojo movement, with a core and simple principle : "teach youngsters/children to code with fun and free". No charge whatsoever. 

Gathering the kids to learn computer is not hard. But choosing what programming language to teach and the tools associated with it, is the hardest challenge so far. If my guess is correct, I bet most of you think : "Basic. Teach them Basic first". That's what I am thinking at first. Using Linux Ubuntu, I can easily found that I can install Basic256 for this job. Having playing around a bit, I seriously think : "So what's next? If I already teach them computer programming using Basic256, then what? How can children leverage their experience with Basic256 to the modern software development technologies? I don't suppose there is a Basic256 powered website laying around in the web...". So, I postponed the idea to teach children Basic256, and move on with assessing which programming language will I use to teach them.

Luckily, throughout the years (span almost 20 years), I've collected skill and experience with many programming languages, as follows:

  1. GW Basic/Basica/QuickBasic (circa '95)
  2. Turbo Pascal (circa '96)
  3. Borland C++ (circa '97)
  4. Java (circa '98)
  5. Delphi (circa '99)
  6. Visual Basic 6.0, Visual C++ 6.0 (circa '99)
  7. PHP (circa 2007)
  8. .NET : C#, VB and C++ (circa 2007)
  9. Cocoa/CocoaTouch (circa 2011)
  10. Python (2013)

This give me quite a deep understanding of all the programming languages above, in the context of choosing what best as first timer programming course. I made some criteria to help me decide what programming language should I use to teach the kids. This greatly helped me narrowing down the list. The criteria are as follows:

  1. The language must be an active language being used in the domain of software development. This will ensure that the experience children gathered will be useful instantly.
  2. To start the code, children must not learn about primitive data type. They just have to write the variable, assign value and use it. No Integer, Byte, Float, or other nonsense. 
  3. Although Object Oriented Programming is a core tenet, children must not force to know what is Class, Object or other OOP stuff, before (s)he even begin to write the code
  4. If possible, it must come from an open source domain. This will encourage children to have a feeling of the beauty of Open Source spirit and how it enabled them to learn new and interesting stuff in the computer programming field.

Using those criteria and my prior programming language experience, I can easily minimize the list of programming language to teach as follows :

  1. BASIC : NO. I consider this as not an active language, so it didn't pass criteria #1. Yes, you can argue with VB.NET being used in ASP which power many websites, but learning those modern BASIC is another journey which will not be covered by their first timer BASIC course. I consider children first timer experience with BASIC will be wasted if they were about to move forward to the modern BASIC. 
  2. All .NET languages : NO. Why? All of them will not pass criteria #2 and #3. They're all compiled language, with strongly typed data type and depend greatly on OOP. Before even begin to write "Hello World!", children must know/see OOP construct such as class. If you think you can skip OOP in Visual Basic.NET.. think again. And if you think, "Teach them Visual Basic 6.0!". It will not pass criteria #1.
  3. Java : NO. Even to write a simple, "Hello wold!", children will have to pass these keywords : class, public, static and void. The first three are OOP construct while the last one is coming from a strongly typed data type.
  4. PHP : ... almost. But, still, NO. I must say that this is almost perfect, in regard that PHP is not a strongly typed language, but it come with one deficiency : children must able to differentiate between an identifier that ended with dollar sign (variable) and those who don't (function). I am sure that it's not going to be a pleasant experience for first timer in coding.
  5. Cocoa : NO. Will not pass #2 and #3.
  6. Python : YES. It pass all the criteria I defined.

Python is very amazing. Maybe I can't emphasize this strong enough, but it really is  : A.M.A.Z.I.N.G. 

Let's elaborate this with my four defined criteria :

  1. It is a very active programming language in the current software development field. Django anyone?
  2. It didn't have an idea about data type. If children want to abstract a triangle with height = 10,  (s)he will just have to write, well, height = 10. I don't have to teach them about data type! And it's a pleasing experience!
  3. By start writing the code, children didn't know that, their code can easily be transformed into a fully qualified Object Oriented Programming code. Yet, (s)he will not even have to read OOP construct at first.
  4. It come from an open source domain programming language.

This is a real code from a python session programming course I teach for 5th grader elementary school children :

1
2
3
4
height = 10
base = 2
area = height * base / 2
print "Area is ", area

Admire its simplicity!

Those code are almost a direct translation from the sentence, "Calculate area of a triangle with height equal to 10 and base equal to 2. Print the result".

 

I use python interactive console for this purpose, and I  ask the children, "What if you want to calculate the area of a different triangle?". Smartly they just write again the assignment, the calculation and print the result. I ask them to calculate three different triangle. And finally I told them, "There is a simple way : you have to def-ine a function to calculate the triangle area". Coded, as follows:

 

1
2
3
4
5
6
7
8
def calculate_triangle(height, base):
   return height * base / 2
result1 = calculate_triangle(10,2)
result2 = calculate_triangle(30,5)
result3 = calculate_triangle(15,2)
print "Result 1 = ", result1
print "Result 2 = ", result2
print "Result 3 = ", result3 

 

Teaching them to def-ine that function is still as natural as the version without function. I also admire the use of indentation in Python to logically group block of code. No tedious BEGIN..END as in Pascal, or cryptic curly braces {} as in C/C++/PHP/Cocoa. A simple as indented code (by using TAB key), already visually adequate and strong enough to denote start and end of block of code.

 

I have't come to the OOP construct, but if it will be eventually, it will be as simple as indenting one more and adding a line that start a class, such as this way :

1
2
3
4
5
6
7
8
9
10
11
12
class Math:
   def calculate_triangle(self, height, base):
      return height * base / 2
triangle1 = Math()
triangle2 = Math()
triangle3 = Math()
result1 = triangle1.calculate_triangle(10,2)
result2 = triangle2.calculate_triangle(30,5)
result3 = triangle3.calculate_triangle(15,2)
print "Triangle 1 = ", result1
print "Triangle 2 = ", result2
print "Triangle 3 = ", result3 

 

Well, of course as it is OOP, I have to teach them about what is the difference between class and object, how to instantiate an object, what is self and how to call method of an object.

 

My next step in teaching children/youngster on how to use Python, is to directly let them work on a PaaS environment in Openshift. Creating their own Python powered website in a free and powerful Openshift environment offered by RedHat. I know, maybe I am too ambitious in that I am too early introducing them to a PaaS environment. But I am sure with a proper teaching style, they will be able to grasp and practice how to work with a Python powered website hosted in Openshift, without knowing the complexity of a web, or a PaaS environment. For now, they have just to know that it works!

 

And that's my next article will be.

Stay tuned! 




Leave comments

authimage
  • Correct. Because of that criteria, I seriously consider teaching them PHP and Basic. But, old Basic still have that $ added for a string variable, so it's a no. PHP almost fell to this criteria, but.. as I said/typed, kids must differentiate between function and variable by means of $ at the end of its identifier. And I always found it hard to introduce useless thing like that...

  • You are right, not having to introduce the data types to the kids is one of the strong selling points of Python as a first language!

    • Joe

Copyright(c) 2014 - PythonBlogs.com
By using this website, you signify your acceptance of Terms and Conditions and Privacy Policy
All rights reserved