1 Introduction

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. The algorithm must be coded in a 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 (boldface terms) 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 course and you can execute and change them right here.

Activity 1.1

Click ‘Run’ (the ► icon) to execute the following program (I’ll explain it later). You should see a message, showing the output of running the code.

If you are reading this on a wide enough screen, you will see side by side the code and the result of running it. If your screen is narrow, you will only see the result of running the code. In that case, click now on the pencil icon to see the code again.

Besides running the code, you can change it.

Activity 1.2

Click with the mouse next to the 7 on the first line, and use the keyboard to replace it with 2 (or another number of your choice). Also replace the 7 in the second line with 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 activities for you to practice coding, by modifying or building upon my programs. You can share your code with friends and family by clicking on the share icon next to the question mark.

If, whilst practicing, you do any mistakes, you can always undo all your changes.

Activity 1.3

In the code window above, click on the 3-line 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? Good. In the next section you will start learning to code.

Start Sequence