Simple coding
Simple coding

Start this free course now. Just create an account and sign in. Enrol and complete the course for a free statement of participation or digital badge if available.

Free course

Simple coding

Simple coding

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, 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 course and you can execute and change them right here.

Wherever ‘Run Python’ appears we recommend that you open the link in a new tab and work from there.

Go ahead, click ‘Run’ (the ► icon) 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? Good. In the next section we will start learning to code.

SCOD_1

Take your learning further

Making the decision to study can be a big step, which is why you'll want a trusted University. The Open University has 50 years’ experience delivering flexible learning and 170,000 students are studying with us right now. Take a look at all Open University courses.

If you are new to University-level study, we offer two introductory routes to our qualifications. You could either choose to start with an Access module, or a module which allows you to count your previous learning towards an Open University qualification. Read our guide on Where to take your learning next for more information.

Not ready for formal University study? Then browse over 1000 free courses on OpenLearn and sign up to our newsletter to hear about new free courses as they are released.

Every year, thousands of students decide to study with The Open University. With over 120 qualifications, we’ve got the right course for you.

Request an Open University prospectus371