Simple Coding - Introduction

Featuring: Activity Activity

Have you ever wanted to try out simple coding? Want to understand the basics of what coding entails? Look no further! 

By: Dr Michel Wermelinger (Faculty of Mathematics, Computing and Technology)

  • Duration 5 mins
  • Updated Thursday 10th September 2015
  • Introductory level
  • Posted under Computing
Share on Google Plus Share on LinkedIn Share on Reddit View article Comments
Print

Software makes the world go round. Cars and TVs have software that controls how they work, and global commerce and finance are impossible without software that control the stocks, carry out payments, find the best transport route, etc.

Coding (or programming) is the construction of software. Coding involves writing a ‘recipe’, which in Computing is called an algorithm, in a so called programming language that a computer can understand. When the computer runs the code we wrote, it follows the ‘recipe’, step by step.

We will use Python, a popular programming language for teaching and for professional software development. You will see that Python code reads almost like plain English. Writing simple programs in Python is not very difficult, once you have come up with the ‘recipe’, the algorithm.

This tutorial shows how to code in Python the basic building blocks of all algorithms, and how to ask the user for input and produce some output on the screen. The skills, concepts and jargon (in boldface) you will learn are the foundations for coding all sorts of apps in all sorts of languages, not just Python.

You won’t have to install any software, the code examples are embedded in this web site (they may take a little while to show up) and you can execute and change them right here!

Go ahead, click ‘Run’ to execute the following program (I’ll explain it later). You should see a message on the right hand side, showing the output of running the code.

You can also change the code. Click with the mouse next to the 7 on the first line, and use the keyboard to replace it by 2 (or another number of your choice). Also replace the 7 in the second line by the same number. Click again on ‘Run’. The message on the right should now read “The sum of 3 and 2 is 5”, or similar.

In the rest of this tutorial I won’t repeat that after you change a program you need to run it to see what it produces.

I will show you various small programs with exercises for you to practice your coding skills, by modifying or building upon my programs. You can share your code with friends and family by clicking on the down arrow next to ‘Share’.

If, whilst practicing, you do any mistakes, you can always undo all your changes. Click on the 3 lines icon in the top left corner. A menu appears. Click on ‘Reset’ and confirm you want to put back the code as it was, before you changed the numbers.

All done? Let’s start learning to code with the next article in this collection - 'Simple Coding - Sequence'.