 Library Subject Guides

# Introduction to coding

### Introduction to coding

What actually is coding? How does it work? And why bother doing it?

On this page we'll look at how computers work, how you write code to tell them what to do, and how to get started with key coding concepts. You'll find the materials for our introductory coding session and some exercises to try out the concepts.

## How does coding work?

Coding is telling a computer what to do, in a way that, with a bit of translation, it can understand.

You give computers instructions in what is known as 'code', in a similar way to how you might have a recipe for how to cook something. You tell the computer about elements it needs to work with (like the ingredients), you give it instructions, and there might be some conditions it needs to choose between (like choosing whether an oven is electric or gas and then following the corresponding temperature).

These instructions you give the computer need to be broken down into every single task, without ambiguity. It can take practice to think as a computer would so you can work out what instructions would need to be written. So how do you give computers instructions they can follow? This exercise is designed to get you thinking more like a computer - by telling a computer how to boil a kettle!

Make a copy of the slide deck below, read the instructions on the first slide, and use the second slide to rearrange the flow chart into an order you think a computer could follow.

## Talking to computers

So, you're giving the computer instructions - but how? The computer doesn't understand our words, or our flowcharts, so what do we do?

That's where the code part comes in. Different coding languages (or programming languages) are how you write the instructions in a way that the computer can interpret them.

Like other languages, these have their own vocabulary and syntax and each one is a bit different, but they have a lot of similarities, including key features that we explore elsewhere on this page. Even using coding languages, the computer cannot understand what you're saying. The instructions still don't mean something that the computer can do yet. Instead, the coding language must be translated into binary (on or off, 1 or 0) for the computer to follow it.

This means that your code, written as text, must be translated, often by a tool called a compiler, for it to 'run' and the computer to follow your instructions. You often need to download a program that will allow you to run the code you've written, or you might write your code in a specific piece of software designed both to help you write code and to run it for you. These can be called coding environments.

## Introduction to coding: what is coding?

In this video, we explore what coding is, what coding languages look like, and why you might want to learn to code.

You'll also find an explanation of one potential solution for telling the computer how to put the kettle on.

## Process of writing code

To start a coding project, you don't just start by immediately writing something in a coding language. You first need to work out what you're doing, and what it needs to do (like with the putting the kettle on flowchart).

1. Define the goal (what are you trying to do with the code?)
2. Design what it needs to do in steps (written out in pseudocode, using a flowchart, etc)
3. Write code for each step Pseudocode is writing out what code will do step by step, but in regular language rather than a coding language.

When you do step 2 and design those instructions, you're creating an algorithm. An algorithm is a precise set of instructions that describes an activity in a way that is repeatable. They can be represented in various ways, such as in pseudocode, a flowchart, or using symbols.

You might have heard about algorithms more widely, and they're often painted as something to be blamed. However, an algorithm is just the set of instructions for how something should be done (whether in code or otherwise), and has to be designed by someone.

Once you turn that algorithm into computer code in step 3, you've written a program!

## Useful concepts in coding

Lots of the key concepts in coding are similar across different coding languages. They often follow similar rules (though there are exceptions) and the terminology can be the same. Here's some useful definitions:

• Variables are values stored in the computer by the code, which can change and can be used by referencing the variable's name.
• Each variable will have a data type, which tells the computer what kind of information is stored in that variable and determines what can be done with that variable. Common ones include numbers, strings (text), and a list of values (also called an array).
• Operators do things with variables, such as calculations or logic. For example, mathematical operators like +-*/ can be used to do calculations, and logical operators like AND, OR, and NOT can be used to combine statements using logic (you might've done this before when searching online).
• Comments are text in the code that is not read by the computer, but are designed to be read by humans. They make it easier for you and others to understand what your code is doing, or to stop a line of code from running when you're testing.
• Loops are a way of repeating a section of code for different values, without having to write the code out many times.
• Conditions allow you to add decisions to code, asking IF something is true or false to decide if some code should run.
• And functions allow you to define a section of code with a name so you can make it run in different places in your code, again without writing it out many times. Our workbook has an introductory look at coding - we recommend you use it alongside the material on this page, the Introduction to coding slides, or the taught session.

## Introduction to coding resources

Our 'Introduction to coding' workshop looks in more depth at what coding is, how to think like a computer, and some key concepts that are useful for learning any coding language. You'll also have the chance to try out some computer code in action.

You can work through the resources on this page or attend one of our training sessions. See our Forthcoming training sessions for the next live 'Introduction to coding' session.

Below are the slides for the Introduction to coding workshop. You can work through these and use the exercises on this page to try out the coding examples and learn more about how they work.

Full Introduction to coding slides on Google Slides

## More introductory coding resources

Once you've worked through these materials or been to the 'Introduction to coding' session, you might want to move on to choosing and learning a coding language or you might want to keep exploring what coding is and some of the introductory concepts.

There are lots of introductory materials out there. You could search online, look on whichever site you like to learn things on, or check out some of the links below. Remember to critically evaluate the resources and look out for free ones - there's plenty out there!

You might want to try a MOOC like the University of Leeds' Computer Programming for Everyone, or further your understanding of computational thinking (like the kettle exercise!) with the Open University's free Introduction to computational thinking online course.

Feedback
X