How to teach math with coding

Math is often at the bottom of the list when it comes to popular school subjects. Some students find it boring. Others find it confusing. Some even find it terrifying. Teachers often hate it too ā€“ many people say itā€™s the hardest subject to teach.

In this post, we want to explain a few ways that math can be supported by coding. Weā€™ll start by talking about some general points, like the way that coding can be used to make numbers a lot less scary, and help children to visualize abstract concepts easily. After that, weā€™ll give some specific examples of actividades de codificaciĆ³n that teach geometry, arithmetic, and graphing.

General principles

To begin with, letā€™s look at how coding can help with general mathematical learning, like a lack of confidence when it comes to numbers, and difficulties visualizing sums. If youā€™d like to jump straight to some specific activities, feel free to scroll down the page.

Patience and problem-solving

Math is all about problem-solving. Thatā€™s pretty much the definition: finding solutions to number-based problems. As luck would have it, coding is all about problem-solving too.Ā 

Itā€™s something every coder is familiar with. Theyā€™ve spent ages working on a piece of code, but when they tell it to run, nothing happens. With a sigh, they now have to track down the problem, and work out how to fix it. This process is called debugging, and itā€™s great problem-solving practice for kids. 

If a child does enough debugging, theyā€™ll learn how important and useful it is to stay calm, patient, and methodical. Getting angry, or frustrated, wonā€™t help them. It will only make things harder. 

The same principle applies to mathematics. When a child is confronted by a tricky sum, it wonā€™t help to tear up the piece of paper, or throw a ruler across the classroom. Instead, they need to take a deep breath, and approach the problem calmly and methodically, just as they would do when debugging a line of code.

In other words, by teaching them patience, coding helps kids to get better at math. This helps in other subjects too, and in general day-to-day life. Patience is such an important skill, and coding is a great way to learn.

Bringing numbers to life

Coding is also a useful way to turn numbers and sums into something tangible and visual. For example, a kid could code a purple cat to walk across the screen. Maybe theyā€™ll start with 10 steps, before changing that number to 20. The kid can see that the purple cat walked twice as far, because 10 x 2 = 20. 

It all sounds pretty straightforward, but for some children, seeing numbers in action can be really, really useful. Abstract numbers are scary, whereas visual examples, like the one we described, are much more familiar and secure.

In the past, to help a student visualize a number, teachers would usually get out some little bricks or beads. A child can count 10 of them, then add another 10, and see how the pile grows to 20. This is still a good option, but it falls short when you get to higher numbers. Nobody has time to count 100 beads, then double that number to 200.

But with coding, kids can make the purple cat walk 200 steps with just a few more clicks. And as they get more competent, they can make things a lot more complicated. 

For example, they could tell the cat to jump after every 20 steps. Now, the child can count the jumps, and see how the cat jumped a total of 10 times over the course of 200 steps. In other words, 200 Ć· 20 must equal 10. Itā€™s another example of an abstract sum being brought to life.

Kids could use this jumping cat for other sums as well. Tell the cat to walk 248 steps, and jump every 7 steps. Before running the code, the kid could grab a piece of paper, and do some long division: 7 into 248. The answer should help to predict how often the cat will jump. 35 jumps, with 3 steps remaining? Run the code, and find out.

Making math less scary

A lot of kids are scared of math. Even the sight of numbers can leave them feeling stressed. Theyā€™re frightened of being wrong, or theyā€™re frightened of looking stupid, and math lessons fill them with dread. But coding can help to ease these fears by allowing children to negotiate numbers in a safe, easy space. 

That example we gave earlier, about the purple cat, was explicitly about practicing mathematical sums, but it really doesnā€™t need to be. Instead, a kid could sit down at their computer, and start coding something unrelated. They could try to make a video game, where the player is controlling a dancing bear, and trying to make it jump through as many golden hoops as possible. 

While programming the bear, the kid will find themselves handling numbers, without even noticing whatā€™s happening. How high can the bear jump, and at what angle? Thatā€™s some basic geometry right there. Whatā€™s the highest possible score, and can anyone beat it? Theyā€™re arranging numbers into order.

Suddenly, they realize that numbers arenā€™t scary after all. If they can handle them inside a coding environment, why canā€™t they handle a mathematical context too? Their stresses and fears will melt away, as they discover that numbers arenā€™t as bad as they always seemed. 

When it comes to coding, no matter the project, numbers are bound to crop up. Whether theyā€™re plotting movement, or tracking high scores, numbers are always needed ā€“ and with time, a childā€™s numerical confidence will grow. 

matemĆ”ticas y codificaciĆ³n para niƱos
Boy carrying a stack of book against Blackboard with mathematical symbols and formula at school

Specific activities

So far, weā€™ve kept things general: coding can make children more patient and methodical, it can help them to visualize abstract sums, and it can make numbers feel less scary. Now, weā€™re going to get more precise, with some specific examples of mathematical principles which can be taught with the help of code.

GeometrĆ­a

Letā€™s talk about that purple cat again. Itā€™s a great way to teach geometry to kids: getting the cat to move around the screen.

For example, you could ask them to code the cat to move five steps forward, then turn 90Ā°, and take another two steps after that. Itā€™s basic geometry. Some addition too. How many steps will the cat take in total? Best of all, itā€™s visual learning. When they run the code, theyā€™ll see the cat slide across the screen.

Now, you want to ask the child to change a few of the numbers. Boost the angle to 180Ā°. Add another three steps, and see what happens. Hopefully, the purple cat ends up back where it originally started.

Now, you can make things harder. Challenge them to make the purple cat walk in a perfect square. Take five steps, turn 90Ā°; take five steps, turn 90Ā°; take five steps, turn 90Ā°, take five more stepsā€¦

How about a triangle? How about a hexagon? The possibilities are endless. We know that a kid could be drawing these shapes on paper instead, with a trusty pencil and protractor, but thereā€™s something more satisfying about moving a purple cat around. The visualization is a lot more memorable, and most importantly, a lot more fun.

If youā€™re looking for a readymade example of this, esta is a good place to start. The cat in this example is orange, not purple, but itā€™s still an excellent activity.

Arithmetic

Learning times tables can be dull and frustrating, but code can be used to enhance the experience, and make arithmetic more exciting. Instead of listing the answers out loud, children can create an interactive game that tests them on their knowledge instead. The program might ask ā€œWhat is 5 x 10?ā€ and the player has to type the answer.

The Raspberry Pi Foundation has a great template for this, which you can access aquĆ­. Instead of a purple cat, the questions are asked by a red monkey. The players get 30 seconds to answer as many of these questions as possible ā€“ a timer is a great way to make this more challenging, and to get kids feeling competitive.

Can they beat their last high score? Can they beat their friendā€™s high score? Suddenly, they donā€™t feel like theyā€™re doing math. Theyā€™re playing a game, and finetuning their skills, and getting better and better as they go.

This doesnā€™t just work for multiplication. They could program the game to ask them about addition, subtraction or division. Older students could get it to give them algebra questions or trigonometry too. Overall, itā€™s a great way to learn, and just like using code to draw geometric shapes, the possibilities are pretty much endless.

Graphing

This is another good way to use coding to teach math, and itā€™s also covered by a Raspberry Pi template. If youā€™re interested in that, you can find it aquĆ­. An important aspect of math is the process of collecting and analyzing data. For example, finding out how many people in the class like pizza, and working out which toppings are most popular. 

Once a child has collected this important data, there are many ways to represent it. They could draw a pie chart on a piece of paper, or use spreadsheet software like Microsoft Excel or Google Sheets. 

Alternatively, they could program these graphs into being. This is higher-level coding than some of the activities weā€™ve already talked about, and it will require students to use a text-based language like Python. But if theyā€™re ready to give it a go, itā€™s an excellent way to practice mathematics through code. 

One thing is certain: it feels a lot more satisfying to build a pie chart using your own piece of code, instead of leaving Excel to do all the hard work for you. This is yet another brilliant example of the ways that coding and mathematics often go hand in hand.

Final words

After reading this post, hopefully you have a good idea of the ways that coding can be used to teach mathematics. The main takeaway is this: it can turn the subject into something fun, and visual, using game mechanics and purple cats to transform a studentā€™s experience. 

There are hundreds of activities for students to try, and with a bit of googling, youā€™ll find plenty of excellent options. Some students already love mathematics, and might not benefit from any of this. But for others, these activities could be life-changing. Instead of growing up with a fear of math, theyā€™ll become calm and confident in the company of numbers, and maybe even find it fun.

We also invite you to try out the Dodo y MatemƔticas course, which combines math and coding in a fun and engaging way.

Ā”Prueba CodeMonkey en casa o en la escuela!

o

para tu escuela / distrito

MƔs para explorar:

Table of Contents

Deja un comentario

Tu direcciĆ³n de correo electrĆ³nico no serĆ” publicada. Los campos obligatorios estĆ”n marcados con *

Este sitio usa Akismet para reducir el spam. Aprende cĆ³mo se procesan los datos de tus comentarios.

SuscrĆ­bete al blog de CodeMonkey

MantĆ©ngase al dĆ­a sobre las Ćŗltimas noticias
Y MƁS INFORMACIƓN SOBRE CODIFICACIƓN PARA NIƑOS.