top of page

Coding and Problem-Solving



We don't teach coding to kids so that they can become software developers in the future. The main reason we teach them coding is that it teaches them how to solve problems. Coding and problem solving go hand-in-hand. Indeed, computer coding is an exercise in problem-solving using the tools provided by a programming language.


Coding is still a subject that's often misunderstood. We have recently created a Parents' Guide to Coding to help parents navigate this subject.


One of the best quotes about coding comes from Apple's co-founder and long-term CEO, Steve Jobs, who said that "Everybody should learn to program a computer, because it teaches you how to think".


How To Write A Computer Program


Consider how you could write a computer program that shows a ball falling from a height and bouncing on the ground. Here are some steps you may write:


  1. Create an object that represents the ball.

  2. Make the ball move down by a small step.

  3. Next, make the ball move down by a step slightly larger than the previous one since gravity accelerates the ball downwards.

  4. Keep moving the ball down, one step at a time, with the step size increasing each time.

  5. Each time the ball moves down, you need to look at the ball's position, though, to make sure it hasn't reached the ground yet.

  6. When the ball does reach the ground, you need to reverse the direction of the ball's movement.

  7. As the ball is now rising, each time the ball moves you need to make the step with which it moves smaller, as gravity is now slowing the ball as it moves upwards.

  8. Once the step size becomes zero, the ball will no longer keep moving upwards. The step size will still be reduced the next time and this will now make the step size negative. So the ball will start falling again.


This example shows how programming requires you to think carefully about the situation you're trying to represent with your computer program and break it down into small steps. You cannot skip any of the steps as the computer program will not work—it will not show the ball falling and bouncing realistically.


Let's look at another example. You want to work out the odds of getting four heads in a row when you flip a coin. You can do this purely using knowledge of mathematics and probability, but you decide you want to do this by writing a computer program. You have a problem you're trying to solve, and if you can find a good and efficient solution then you can get the computer to do the hard work for you.


Here are the steps you could use:


  1. Get the computer to choose a random item from "Heads" and "Tails".

  2. If it's "Heads", get the computer to choose again, for the second time.

  3. If it's "Heads", get the computer to choose again, for the third time.

  4. If it's "Heads", get the computer to choose again, for the fourth time.

  5. If it's "Heads", keep a note that you've managed to get four heads in a row.

  6. If you get "Tails" in any of the above steps, do nothing! Just move on.

  7. Now, repeat Steps 1-6, let's say, a million times. You'll end up with a tally showing how many times you got four consecutive "Heads" out of the million attempts. If you want a more accurate estimate, repeat for 10 million times or more if you want.


You still need to know how to translate these steps from English into Python or whatever programming language you'd like to use, but that's only one part of coding. The thinking and problem-solving aspects of computer programming are, in many ways, the most important part. It's also the most exciting part of coding.


Solving a problem and writing a computer program that works and does what you want it to do is very rewarding and satisfying.


Problem Solving In The Curriculum


Learning to solve problems has always been a part of the curriculum of what children learn. Some topics in Maths are particularly suited to train children not just to learn those Maths topics but also to learn how to solve problems.


In recent times, there has been a lot of discussion about introducing more critical thinking in our children's education. However, good schools and good teachers have always included this as it's always been a key part of a good education.


Coding is a subject that provides plenty of opportunities for problem-solving. It's a great subject to add to the others, such as Maths, as a way of both teaching children a new skill but also, more generally, help them think about problems and find creative solutions for them.











84 views

Comments


Python Coding for Young People

CT-Unlimited-FinalRAW-transparent.png

Codetoday Unlimited is for the curious teenager or preteen keen to learn proper Python coding. Stephen's courses start from the basics and carry on to intermediate and advanced levels.

Python Coding for Adults

The Python Coding Place is Stephen's platform full of courses and other resources for beginners and intermediate learners. The focus is on clarity and Stephen's unique communication style.

bottom of page