Computer Science, Early Childhood Education, K-12, Math, Open Source Education, Parents, Personalized Learning, Required, Technology - Written by on Thursday, December 13, 2012 6:00 - 0 Comments

Jonathan Mugan: Teaching Your Child To Hack Math

Hacker in the darkness powtac via Compfight

By Jonathan Mugan, Columnist

There are many educational apps, but the power of these apps to teach is limited by the imagination of the designer. A theme of The Curiosity Cycle is that learning should be driven by the imagination and creativity of the child. Programming is an ideal way to do this. Many parents may be drawn to using apps for education because they themselves don’t know how to program or how to use programming as a teaching tool. This blog post will show you how to do both using a free, interactive, and light-weight programming language called Python.

We will focus on using programming to teach math.  In the modern world, math is implemented in programming, much like how hydrogen and oxygen implement the phenomenon of water. This embodiment of math in programming enables your child to poke and prod math like it is a living thing, allowing learning to happen through experimentation.

Your child can also use programming to build a math toolkit that will be useful  later. This toolkit can be used to check homework and do class projects. When your child learns a new algorithm in school, such as long division, he or she can program the algorithm in Python and use it to check intermediate computations. Having access to this toolkit and the ability to expand it will foster a habit of computational thinking. Your child can grow to be like a digital sorcerer casting spells and learning new ones.

INSTALLING AND RUNNING PYTHON

To install Python, go to http://www.python.org/getit/ and pick the link that corresponds to your computer. I use Python 2.7.3.

For a 32-bit Windows machine:
http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi
For a 64-bit Windows machine:
http://www.python.org/ftp/python/2.7.3/python-2.7.3.amd64.msi
There are also the equivalent Mac installers below those on the page.

You may have to set the path so Windows knows where to find Python.

Windows 7 and Vista
1. Start -> Computer
2. System properties from the menu up top.
3. Advanced system properties from the menu on the left.
4. Advanced tab -> Environment Variables button on the bottom
5. Under system variables choose “Path”

Windows XP
1. Start -> Control Panel -> System
2. Advanced tab -> Environment Variables button on the bottom
3. Under system variables choose “Path”

Then add “C:\Python27″ to that path. Note that there are no spaces, and each entry is separated with a semicolon.

To use Python in Windows, click on the Start (Windows) button and type “cmd” into the little run/search box. When the command prompt comes up, type “python.” You will now be in the Python interpreter and can just start typing commands. (For a Mac, you similarly need to bring up a terminal window.)

If you followed my blog post here and installed Ubuntu, you already have Python installed. Just hit Cntl+Alt+t to bring up a terminal and type ‘python’.

PROGRAMMING WITH YOUR CHILD

The interactive nature of Python is a big part of how we can use programming as a teaching tool. It makes it possible to turn learning into a game.  You can play “stump the kid.” You type in a command, and your child tries to guess what the computer will say. Then your child can take a turn at stumping you. To make it even more fun, you can hook up a laptop to a TV and see the action on the big screen.

Basic arithmetic

You can practice basic arithmetic with your child by just typing in math.

Fractions and decimals

When you try division, you may notice an odd thing. 5 / 2 = 2. That’s because Python thinks you want an integer answer (silly). You have to type “from __future__ import division”.

You can show for common fractions that you get decimals. You can quiz your child on what the decimal value will be.

Please Excuse My Dear Aunt Sally

One area where the implementation of math in programming may produce a fun surprise for your child is in the order of operations. When I was in 7th grade, I learned the phrase, “Please Excuse My Dear Aunt Sally.” This phrase was a mnemonic to help us remember what was evaluated first in a math expression: parenthesis, exponents, multiplication, division, addition, and subtraction. In reality, multiplication and division are done left to right (neither has precedence over the other), and addition and subtraction are also done left to right.

You can see this in action. If your child has not studied order of operations yet, he or she will likely say that the answer to 3 + 4  * 2 is 14. Python and Aunt Sally agree that it is 11.

Introducing variables

You can introduce variables, which gets your child started toward algebra.  In Python, a single equal sign ‘=’ is used for an assignment of a value to a variable; a double equal sign ‘==’ is an operator that checks if the two values are the same, as we will see in the next section. Note that your child may get confused between strings and variables. A string, such as ‘dog’, is in quotation marks.

Conditionals and logic

You can use the ‘if’ statement for conditional execution. If a command goes more than one line, just hit return to continue typing. Then, to evaluate, hit return twice.

You can also test for inequality, as shown below.

Now that we are using more syntax, it is a good time to point out that a tutorial of syntax can be found athttp://docs.python.org/2/tutorial/.

Errors and flapdoodle

My kids love when the computer says something crazy like when you divide 1 by 0.

You can also use a variable before it has been defined to get some more gobbledegook as output.

These kinds of nonsensical responses may lead your child to the wow-computers-are-stupid stage of learning programming. In this first stage of programming, the  literal mindedness of computers can be a significant obstacle.

The bad news is that you have to tell computers everything you want them to do in excruciating detail, but the good news is that you only have to tell them once.

Modules and functions

You can store your commands in a file so you don’t have to type the same things over and over again. You can also define functions to put in this file. In Python, this file is called a module, and it will end with the suffix “.py”. We will assume that your module is called mymodule.py.

You can create mymodule.py with a text editor, such as Notepad, and save it in the directory where you run Python. (It doesn’t have to be in that directory, but having it there saves us from having to tell Python where it is.)

When you start Python, you can then type “from mymodule import *” at the command prompt.

Here’s an example of a function in python:

Note the indentation. Python uses indentation (a convention is to use 4 spaces) to determine the nesting of statements.

Every time you change mymodule.py, you will need to quit Python (do this by hitting Ctrl-z) and reload it using “from mymodule import *”.

To avoid having to type “from mymodule import *” each time you start Python, you can create another file, we’ll call it startup.py, that only contains “from mymodule import *”. And then you can set a special environment variable to run that startup module each time Python is loaded. To do this, set the environment variable PYTHONSTARTUP to point to your startup file (instructions for Windows are given below).

Windows 7 and Vista
1. Start -> Computer
2. System properties from the menu up top.
3. Advanced system properties from the menu on the left.
4. Advanced tab -> Environment Variables button on the bottom
5. Under system variables click “New”

Windows XP
1. Start -> Control Panel -> System
2. Advanced tab -> Environment Variables button on the bottom
3. Under system variables click “New”

COMING IN FUTURE POSTS

In future posts, I will discuss more about functions. We will also talk about loops so your child can multiply a number by 10 until it is so big it covers the whole screen. From there, we can introduce all kinds of concepts such as factoring, identifying prime numbers, finding the greatest common denominator, and sorting.

We will also look at recursive functions (functions that call themselves) such as the one below.

Jonathan Mugan is a computer science researcher specializing in machine learning and AI. He completed a postdoc at Carnegie Mellon University and  received a PhD in Computer Science from the University of Texas at Austin. He recently completed a book: The Curiosity Cycle: Preparing Your Child for the Ongoing Technological Explosion. You can follow him @jmugan. 



Leave a Reply

Comment

Campus Buzz


We welcome Tips & Pitches



Latest WA Original Features






  • Twitter feed loading











APEI36.16  chart0.00  chart +0.00%
APOL20.80  chart0.00  chart +0.00%
AAPL521.7302  chart0.00  chart +0.00%
BPI10.39  chart0.00  chart +0.00%
CAST0.09  chart0.00  chart +0.00%
CECO3.33  chart0.00  chart +0.00%
COCO2.54  chart0.00  chart +0.00%
CPLA28.8784  chart0.00  chart +0.00%
DV24.30  chart0.00  chart +0.00%
EDMC5.55  chart0.00  chart +0.00%
ESI18.32  chart0.00  chart +0.00%
GOOG722.36  chart0.00  chart +0.00%
LINC5.41  chart0.00  chart +0.00%
LOPE24.19  chart0.00  chart +0.00%
PEDH0.17  chart0.00  chart +0.00%
PSO19.64  chart0.00  chart +0.00%
SABA8.36  chart0.00  chart +0.00%
SCHL28.79  chart0.00  chart +0.00%
STRA58.2609  chart0.00  chart +0.00%
WPO368.48  chart0.00  chart +0.00%
2012-12-20 16:00


Cost of Education, Domestic, For-Profit, Friend, Fraud, or Fishy, Graduation Rates, Infographics, Recruitment, Required, Universities & Colleges - Dec 18, 2012 6:00 - 0 Comments

Infographic: A Comparison Of For-Profits v. Non-Profit Online College Data

More In For-Profit


Blended Learning, Continuing Education, Domestic, K-12, Personalized Learning, Required, Technology - Dec 20, 2012 6:00 - 0 Comments

Terry Heick: The iPad’s Past, Present & Future In Learning Environments

More In Technology


Cost of Education, Domestic, For-Profit, Friend, Fraud, or Fishy, Graduation Rates, Infographics, Recruitment, Required, Universities & Colleges - Dec 18, 2012 6:00 - 0 Comments

Infographic: A Comparison Of For-Profits v. Non-Profit Online College Data

More In Friend, Fraud, or Fishy