OCR Grade Boundaries – 2024

Two things to remember when looking at these numbers:
- 4 is a pass which is good but unlikely a grade you’d want if you wanted to do more computer science. A 6 would be good and requires to get 51 on average across the two papers (102/180). Also look at the score in paper 2 – to get an 9 in this paper you can only drop 10 marks from 80 – tough!
- The computer industry is big but can be divided into infrastructure (includes network and support) and software development. These papers divide the GCSE into roughly these sections. So if you like on paper and hate the other then you can get a good mark if you do well in one and not the other. A score of 60 in paper one and a 42 in paper two you get a good 6. This means even if you hate programming (there a fair number of network engineers that hate coding and developers that hate a firewall!)
Source: https://www.ocr.org.uk/Images/714692-gcse-grade-boundaries-june-2024.pdf
To get to the grade that you are after you have to be able to do a couple of things: 1) know the course material and 2) write the answers down that can be marked. Sounds obvious but it’s not what you know; it’s what you can show (what can be marked).
OCR Specification
To know more about the OCR exam we need to look at two things. First the OCR specification which shows what the subject contains and, importantly,
Past papers: https://www.ocr.org.uk/qualifications/gcse/computer-science-j277-from-2020/assessment/
Sample papers: https://www.ocr.org.uk/Images/552500-computer-systems-.pdf
Past Papers:
Computer Systems – May 2022 https://revisionworld.com/sites/revisionworld.com/files/imce/677830-question-paper-computer-systems.pdf
Mark Scheme – Computer Systems
Sample papers: https://www.ocr.org.uk/Images/552502-computational-thinking-algorithms-and-programming.pdf
Past Papers – May 2022
Mark Scheme
Specimen and past papers are essential tools in not only understanding the topics that are covered but also the structure and type of questions you will be examined on. If you are on an exam board with a screen test then practice this format as well so you are prepared for the exam in terms of the challenge in the time available (one of the best ways of getting good grades is to answer all the questions clearly).
For OCR exam are broken down into the following papers
- J277/01: Computer systems (80 marks – 50% exam – 1’30”)
- 1.1 Systems architecture
- 1.2 Memory and storage
- 1.3 Computer networks, connections and protocols
- 1.4 Network security
- 1.5 Systems software
- 1.6 Ethical, legal, cultural and environmental impacts of digital technology
- J277/02: Computational thinking, algorithms and programming (80 marks – 50% exam – 1’30”)
- 2.1 Algorithms
- 2.2 Programming fundamentals
- 2.3 Producing robust programs
- 2.4 Boolean logic
- 2.5 Programming languages and Integrated Development Environment (IDE)
| Component 01 – Computer Systems | |
| Section 1 – Components of a Computer System | Section 2 – Data Representation |
| Computer Systems The CPU Memory CPU and System Performance Secondary Storage Systems Software – The OS Systems Software – Utilities | Units Binary Numbers Hexadecimal Numbers Characters Storing Images Storing Sound Compression |
| Section 3 – Networks | Section 4 – Issues |
| Networks – LANs and WANs Networks – Hardware Wireless Networks Client-server and Peer-to-Peer Networks Network Topologies Network Protocols Networks – The Internet Network Security Threats | Ethical and Cultural Issues Environmental Issues Computer Legislation Open Source and Proprietary Software |
Component 02 – Computational Thinking, Algorithms and Programming | |
| Section 5 – Algorithms | Section 6 – Programming |
| Computational Thinking Writing Algorithms – Pseudocode Writing Algorithms – Flowcharts Search Algorithms Sorting Algorithms | Programming Basics – Data Types Programming – Casting and Operators Programming Basics – Operators Constants and Variables Strings Program Flow Boolean Logic Random Number Generation Arrays File Handling Storing Data Searching Data Sub Programs |
| Section 7 – Design, Testing and IDEs | |
| Structured Programming Defensive Design Testing Trace Tables Translators Integrated Development Environments |
From the above breakdown we can think of the course of computing systems and computer programming or computer (and network) hardware and computer software. As it likely to be the first, foundational qualification it makes sense to break it into these two topics as nearly all computer qualifications, skills and jobs are in the areas of computer hardware, computer programming, and networking (which is a bit of hardware and software). A relatively new topic of Cloud computing also blurs the lines between hardware and software as the computing power you would normally get through a physical real computer laptop sitting on your desk is provided remotely through the internet.
Study Aid Books
I’ll be using the CGP GCSE OCR Computer Science For the Grade 9-1 Exams. CGP provide a lot of materials to practice for the exam including past papers (very important past papers!)
With a full coverage of the syllabus we can now look into how we start to break this subject down into understandable blocks that we can remember to ace the exam. The way to do this is to divide the subject into the physical and the digital. These two areas can be seen as electronic engineering (chips, ram, hard drives, cables, etc) and software engineering (programming, maths). One reason to do it this way is to start thinking about what comes after this GCSE as computer science is wider than spending a career programming.
OCR – Component 01 – Computer Systems
4 sections: computer components, data representation, networks, issues [with using computers]
For Component 1 the key thing to understand is what you don’t need to know and that is programming a computer. At the end of the component you will know how a computer works for people and why it doesn’t work.
Section ONE – Components of a Computer System
Computer Systems
We start with the very basics – what is a computer system? At the very basic level a computer is a machine that processes data. Simple. Data is some value from the environment either detected or created. This recorded data can be processed into either more data or, if it has meaning, information. This is what computers do – turn data into information and from that knowledge then wisdom.
Computers produce information from data from two types of component: physical components and non-physical components. Physical components are classed as hardware and non-physical as software. Software is also known as programs or applications that process specific data into specific information.
Computers can be divided into two different types depending on the data they process.
- General purpose computer, like a personal computer (PC – Windows, Mac). The workhouse or more precisely workstations. General purpose machines can do a lot of different things with software that works on generic hardware. It’s the computer you are reading this webpage on through a web browser’s on an operating system (OS).
- Specialist purpose computer, like a servers or super computers. General purpose computers or workstations are for one person but when you need to connect resources up then specialist computers are going to be needed to do specialist jobs. The reason for the specialisation can be due to the hardware components of the machine or it can due to specialist software that needs to run on it like a file server or a web server. Different operating systems are often found on them commonly linux rather than windows of Mac OS.
You can have special purpose computer software running on general computer hardware like a file server mentioned before. But for some special purpose computers specialist hardware and software is used. These machines are designed to do specific things like weather forecasting, or banking, or other specialist industries. These machines are often built specifically to do the specific process. For example if you want to do some super computing like for bitcoin mining you need a lot of specialist processing and for that you may want an application specific integrated circuit (ASIC – not to be confused with ASCI which is may to code symbols, like letters, more later). You may know a ASIC already – it provides the screen your reading this screen off – the graphics card is a ASIC. Graphic cards are also used to mine it coins as they have similar computing functional that it takes to mine bitcoins (a subject not covered in this GCSE.
Another example of a specialist purpose computer is a quantum computer. QC are very specialist as unlike the general and specialist computers mentioned above QCs use a special way to store and then process data in the form of Qbits or quantum bits – again not covered in this course.
Computers aren’t only found as general or specialist purpose but in devices to help control how they work. If you have a look around a kitchen there are appliances that have computer like functionality – they take a data input, process the data, output the data to create an outcome. Think of any application that has programs that you either choose or you can choose like setting a microwave to ‘defrost’ or a washing machine to 40 degree cycle with 400 spin. These have embedded systems which are computers built into the machinery of the appliance. The embedded systems can be classified into two main functions: 1) monitor and 2) control which work together. In many appliances these embedded systems are not seen as they keep your car on the road or prevent your dishwasher from flooding. These systems are there to control the machinery and, importantly, not going rogue making them at best not work efficiently or at worst dangerously.
It’s worth considering which appliances don’t have embedded systems just to get the full picture. An electric kettle doesn’t have an embedded system – it has an On and Off switch where if set to On it stays on water in the kettle boils or, if you’re a total nerd like me when the water boils it creates a vapour (the cloudy stuff you see) which pushes itself down a tube due to it being a higher pressure than air on to a bimetallic strip which is made of two metals, where one expands more than the other causing the strip to bend cutting out the electricity. You can test this by simply leaving the lid of the kettle. Anyway back to embedded systems.
Embedded system are made up of electronic components – circuit board, diodes, resistors, transistors etc. They are designed specifically for the system they are monitoring and controlling. For the exam be able to identify appliances that have embedded systems and describe what the embedded system does even if it says state just the appliance. The reason is the mark scheme may give a list of acceptable answers plus ‘any acceptable answer’ so to make it acceptable for the nice exam marker just state what the embedded system does in the appliance (probably not smart to trying and convince the exam marker that a kettle has an embedded system).
Calculators, embedded system, computer
One thing that it’s worth covering at this point is where does a “computer” start? Is a calculator a computer? Is a smart phone with a calculator a computer? Well it can get tricky in a strict definition of a computer as some calculators are computers as they can do the core things a computer can do.
We can define a computer by its function. The word comes from Latin computare which means to count or calculate or work out. In more modern uses of the word computers were people who would do calculations to produce a standard output such as calculating artillery projections. Over and over again – taking some input, doing a known calculation, producing an output that would be the same if you repeated the process. This is exactly what a calculated does like all machines. The difference between a calculator and these humans is that a calculator can’t do new calculations once built whilst a human can as they can be given new instructions or a new program. Computers are programmable with new processes whilst non-computers tend to fixed in their function.
The other way we can define a modern computer is by what it’s made up off – the bits and pieces that you would need if you were going to build a computer yourself or things you would expect to see when buying one. The course goes into more detail into each component but the main parts are:
- Power source – something to power the computer which runs on direct current so this will be power unit for a desktop or server, or a battery for a laptop or smart phone
- Motherboard – a printed circuit board which connects the power supply to all the other components of the computer together through etched copper tracks. Contains input and output connectors for external devices such as control devices (keyboard, mouse, trackpad) and peripherals for physical jobs like printing. The motherboard has the BIOS (basic input/output system that contains the instructions on how to get the computers up and running before the main operating system (OS) is loaded. The information for the BIOS is stored as Read Only Memory (ROM) a for of computer memory that is stays when the computer is switched off. The BIOS loads very quickly when the computer starts (boots up) with the keyboard working straight away. This allows the keyboard to interrupt the boot sequence by typing or holding down certain keys.
- Secondary storage or a hard drive – either a whirring magnetic drive or a solid state drive that stores programs and data permanently (doesn’t disappear when the power is turned off). The operating system (OS) is nearly always installed in the hard drive which is loaded once the basic boot operations are competed through the instructions set out in the BIOS.
- Primary storage or Random Access Memory (RAM) – sticks of magnetic storage like a hard drive but are used as temporary storage for inputs before being processed and temporary storage for outputs after processes. The things you can see on your screen at the moment are stored in RAM and you can test this by powering your machine off without saving and the information will be gone (always save anything important to your hard drive just in case you do lose power unexpectantly
- Central Processing Unit (CPU) – the thing in the computer that does the compute. We’ll go into details in a minute but for now it takes inputs and instructions from RAM, executes instructions on the input before returning the output once all the instructions are complete or it’s instructed to stop.
- Specialist compute boards or cards – child boards to the mother board that do specialist computer jobs notably a dedicated graphics card going to the monitor or network card with either a wired or wireless connection. These are found in desktop computers as plug and play (PnP) cards. For laptops these are part of the main motherboard to keep the size down (the form factor)
That’s it. For the exam you may be asked to name different parts of a computer so do know your way around a computer.
The CPU
As a computer is a processing machine it needs three things: 1) something to process (data) 2) processing machine 3) output storage. The processing machine in a computer is called the central processing unit or (CPU). Computers now have lots of processing units to do specific/specialist work but the CPU is the one that controls the overall coordination of processing for a general computer like the one you are probably using to read this page. The idea of a CPU is becoming a little dated as computers improve as there can use different types of processing which can be external to the computer being worked on but every computer has a CPU at the centre.
Three parts of the CPU
Control Unit
Arithmetic and Logic Unit (ALU)
Registers
Memory
CPU and System Performance
Secondary Storage
Systems Software – The OS
Systems Software – Utilities
Section TWO – Data Representation
Units (of a computer)
Binary Numbers
Hexadecimal Numbers
Characters
Storing Images
Storing Images
Compression
Section THREE – Networks
Network – LANs and WANs
Network – Hardware
Wireless Networks
Client server and Peer-to-Peer Networks
Network Topologies
Network Protocols
Networks – The Internet
Network Security Threats
Section FOUR – Issues
Ethical and Cultural Issues
Environmental Issues
Computer Legislation
Open Source and Proprietary Software
Component 02 – Computational Thinking, Algorithms and Programming
Section FIVE – Algorithms
Computational Thinking
Three key techniques for computational thinking
- Decomposition: breaking stuff into smaller parts that would then connect together
- Abstraction: concentrating on the most important function or outcome dismissing other information for the time being
- Algorithmic thinking: thinking how to solve a problem through repeating logical (yes or no) decision making
Writing Algorithms – Pseudocode
Psuedocode is a way of starting to think about how the computer program could be written. Pseudocode has all the basic computer language structure and elements (syntax) but lack specific syntax for a given language.
To be able to use pseudocode you have to know how a computer can read a language. Although there are many computer languages they all follow and contain the elements we covered next – capturing data, processing, presenting data.
There are no formal rules for writing pseudocode but there are some guidelines that are fundamental when coding in a language such as declaring variables to put things in, arithmetic on numbers (integers, and fractions), character manipulation, and lots of functions like print or save a document.
An example would be to print a name to a screen from a user.
Normal English
Ask user to enter their name on the screen
Store then entered name
Print name to the screen
Pseudocode
name = input(“Enter your name:”)
print(name)
At the moment don’t worry too much and pseudocode. You will learn more about how to think in algorithms aka programming as we goo through the syllabus.
Writing Algorithms – Flowcharts
When writing programs you need to be able to follow how the data comes in, how it’s processed and how it’s stored afterwards. To help with this flowcharts are very helpful as you can track how the data is taken in, processed, and outputted. The power of flowchart is the when decisions are made (if data is this then do that …) and doing the same thing over and over again or loops. The ability to do things over and over is exactly what algorithms are used for to make calculations easier and faster.
Search Algorithms
There are two things that you will need to do a lot of when programming – searching for stuff and sorting stuff. Some times you have to sort stuff before your search and some times you have to search for stuff and then sort the bit you want.
For the GCSE there are two search algorithms
Linear Search – Unordered List
The linear search is how you search for things in a list. You start at the top and then move down the list until you find the thing you are looking for. This is fine way to look for something especially if you know two things: 1) the thing is in the list so it’s not a waste of time and 2) it’s not a very long list (even if computers are very fast)). So, if you have a short list the linear search is a good one.
Binary Search – Ordered List
The binary search is the more complex than the non-ordered linear search in two ways. First the list has to be ordered numerically 0 > end of list e.g. 0, 1, 2, 3, 4. Once it’s ordered we know two things – the things in the list or the position they are in the list, and the length of the list.
With this information we can loop through list by search in the middle of the list each time. If the item is in the half selected we can ignore the other half hence binary search.
For example – finding Curve in the dictionary. There are 26 letters in the English dictionary with M at middle point 13. First we see if it is the correct letter – nope. Then we ask is the position in the first half or the second half of the dictionary <M or M>. C is in the first half. Repeat for the next half which is letter G (we round up). Again G is not C and is in the first half. Repeat until we have divided and checked until we get to C which takes 4 rounds.
As you can see in the case of finding C from an ordered alphabet only took 3 rounds but 4 with the binary search. Linear search is good for short lists but very bad for long lists but it does take more effort to use. For the GCSE these are the two searches you need to know so learn how and where they work.
Sorting Algorithms
The binary search needs the list to be sorted before it can be searched. For GCSE there are three ways to sort a list into an order.
Bubble Sort
The first sort is another that we do ourselves when we sort things from a very early age. We look at two things and put one in front of the other based on a condition. For example with colours we use the rainbow as an agreed order – Red > Orange > Yellow > Green > Blue > Indigo > Violet. If we were given three colours, say green, red, blue, we would first compare green with red and put red before green. Next we compare green with blue which is correct so we would leave that pair as it is. This sorts the list into red, green, blue.
With numbers it’s easier for a computer as they are good with numbers which have a natural order either big or smaller. Taking a list of numbers 8, 6, 2, 3, 9 we do the same process with the colour we compare the first two and switch if the second number is bigger than the first in this example 8 vs 6 = switch = 6, 8. We repeat this process with positions 2 and 3 which is 8 v 2, again a switch. The sort finishes when 8 faces off to 9 which is bigger so it doesn’t switch
| Position 1 | Position 2 | Finished |
| Round 1: 8 6 2 3 9 Round 2: 6 8 2 3 9 Round 3: 6 2 8 3 9 Round 4: 6 2 3 8 9 | Round 1: 6 2 3 8 9 Round 2: 2 6 3 8 9 Round 3: 2 3 6 8 9 | Sorted List 2 3 6 8 9 |
As you hopefully can see the result of this sort is that things start on one side and shift to the right. If we imagine that the sort is vertical not horizontal then the bigger things (colours or numbers) bubble up from the bottom to the top like a bubble. Whilst slow the bubble sort has a couple of advantages especially if you are not in a hurry. First it is a fast way of checking if a list is ordered in the first place. Second, and it’s related to the first point is that it only needs to work with the original list instead of having to make copies. Normally not a problem but when memory is a problem or super speed is vital copying stuff around is not helpful. All the same the bubble sort is not great for very big lists of sort.
Split – Merge Sort
To work on big lists we need to divide and conquer. Remember computers only really work in yes or no so splitting things into 2 from 1 is a common practice. With that in mind we turn to the Split – Merge Sort.
The split – merge takes the apart until it is in individual parts from where it will be recomposed. There are couple of key things to remember when working with split merge. The first thing is to remember how many parts where in the list at the start and the second is we are going to compare values systematically to rebuild the list.
We’ll start with a simple case so you case see how it works. The list is only 4 parts, all numbers are the wrong way round.
The list starts unordered with 4 items. When we have finished we will end with an ordered list of 4 items
[ 4 | 3 | 2 | 1 ]
split into 2 smaller lists
[ 4 | 3 ] || [ 2 | 1 ]
split into individual parts
[ 4 ] || [ 3 ] || [ 2 ] || [ 1 ]
Now we compare the individual parts to build back using the reverse process so we draw out the blocks we will we use
[ ? | ? ] || [ ? | ? ]
[ ? | ? | ? | ? ]
First round – pairing up:
1. 4 vs 3 -> 3 wins so 3 is place in the first slot of the pair and 4 takes the second slot
2. 2 vs 1 -> 1 wins so 1 takes the first slot of the pair and 2 takes the second slot
This gives us
[ ? | ? ] || [ ? | ? ] => [ 3 | 4 ] || [ 1 | 2 ]
At this point it’s like a binary sort comparing one value against another. Next comes the magic of the merge.
The first thing is to compare the 1st value of the 1st pair with the 1st value of the 2nd pair and see who wins. The lower value wins and goes into the first slot of the 4. Then
3 vs 1 -> 1 wins and goes into slot 1. 3 is still in the game.
3 vs 2 -> 2 wins and goes into slot 2.
3 goes in slot 3 and
4 goes into slot 4.
[ 3 | 4 ] || [ 1 | 2 ]
[ 1 | 2 | 3 | 4 ]
When working with the split merge sort thing of it like a battle where one part takes on another part and the winner gets a slot and the other has to battle on until they do which will be the right side of the list. As you can see there is more work than for the binary (bubble) sort but it work very well for very long lists as it splits the list into smaller parts and then reforms rather than having to compare values that have already been compared. Talking of which – our last sort for the GCSE – insertion sort.
Insertion Sort
After the split merge sort we return to an easy, if not efficient, way to sort a list and it’s the most human way similar to the binary sort. For the insertion sort imagine you have a vertical list of objects and we want to sort them into a list – let’s use fruit: satsuma, lemon, strawberry, water melon, orange, apple, banana, and cherry.
The insertion sort starts by comparing the second position with the first and inserting the second one before the first if the second one is less.
Then we repeat this by moving the third position and compare its position to all the values before it.
In our fruit example we start by comparing position 2 with position 1: lemon vs satsuma. Lemon is higher in the alphabet so we insert lemon into position 1 and satsuma takes position 2. We repeat this by going through the original list position to where it should be inserted like you would insert a playing card into a set of cards you’ve been given.
| Index | Fruit / Round | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 1 | satsuma | lemon (+) | lemon | apple (+) | apple | apple | apple | apple |
| 2 | lemon | satsuma | satsuma | lemon | lemon | lemon | banana (+) | banana |
| 3 | strawberry | strawberry | strawberry (-) | satsuma | satsuma | orange (+) | lemon | cherry (+) |
| 4 | apple | apple | apple | strawberry | strawberry | satsuma | orange | lemon |
| 5 | water melon | water melon | water melon | water melon | water melon (-) | strawberry | satsuma | orange |
| 6 | orange | orange | orange | orange | orange | water melon | strawberry | satsuma |
| 7 | banana | banana | banana | banana | banana | banana | water melon | strawberry |
| 8 | cherry | cherry | cherry | cherry | cherry | cherry | cherry | water melon |
The insertion sort is not great with big lists as the whole list has to be compared each time but it’s logical, works with short lists, and is low on memory just like the binary/bubble sort we worked through earlier.
Section SIX – Programming
Data types
Casting and Operators
Operators
Constants and Variables
Strings
Program Flow
Now we have covered how to capture data and manipulate it we need to put that together and start to think about how it all comes together to create a computer program that the machine can use by taking in the input, do the process, and out the output. The first stage of this we have looked at already with the three parts of computer thinking: 1) decomposition, 2) abstraction, and algorithmic (logical) thinking. These three parts where supported by using flow diagrams to show how the process works by taking in data, comparing it, using it, then outputting it. In order to do this we need to know how to turn the workflow into a high level design for a program that could be sketched out with pseudocode before deciding on a language to use.
The flow of a program can be broken into two things: decision making and looping (repeating the same code many times). You can have programs that don’t have either of these things. We’ll look at these programs when we look at sub-programs that are designed for a specific function within a program but lets start with the basics.
Decision Statements
When you start with computer programming the very first thing you tend to write is “Hello World”. The program tends to hard code the print function with the string “Hello World” along these lines print(“Hello World”). Once you’ve mastered that one then it can get more interactive with taking an input from the user along the lines:
username = input(“Enter username:”)
print(“Username is: ” + username)
From this you can see we took the input entered by the keyboard, stored it in a variable called username and the printed “Username is: ” whatever was stored in the variable. Excellent. Where it starts to get interesting is when we want to check what’s entered and then respond to that. Once we need to check and respond we need to use a conditional statement. For the GCSE there are only two to know and they are the heart of programming – If, Else and Switch.
If-Then-Else Statements
We can use If Else statements to check for the value of variable and then decide what to do. For example we can check the name entered and then give a different answer depending on what’s been entered.
username = input(“Enter username:”)
If username = Bob
print(“Hello Bob”)
Else
print(“Your’e not Bob”)
The “if” part is checking for a true statement. Is it true that the username is Bob? Yes – OK do the next thing. The opposite is not checked (Is it false?) as it’s the other route the code can take. When you use an If statement you need to include an Else statement otherwise the computer doesn’t know what to do.
It’s really important you know when to use an if and the order in which it is used. Ideally the if checks something quickly and then stops. In the name check above if we wanted to do a lot of stuff for Bob then it would be better to check that it’s not Bob and then shut that stream down. Otherwise you’ll have a tonne of code to go through and then the else statement at the end. We’ll talk about code structure later.
Nested If Loops
It is possible to put an If inside an if (which I guess would be iiff? anyway …). This means you do ask another question within a question. In the example below we ask another question If Bob has been entered as a username. We ask if it’s the morning or not the morning and then depending on the answer give a specific greeting.

We could have done this another way by not using a nested If. We could have worked out the morning or non-morning (afternoon) before the loop and used it for both answers e.g. Good Morning. You’re not Bob. Good bye. We may decide to do this if we don’t want to spend any time or power on a calculation we don’t care about – we don’t mind being short and rude to usernames we don’t know. So use nested Ifs if you want to do specific checks that are only for that path.
Switch Statements
As computers only work in Yes and No surely Ifs are the only way of checking something for decision making? Well, sort of. The other check you need to know for the GCSE is the Switch or Case statement.
In the example below we take the inputted user name and compare it to a list of welcomes depending on the input.
username = input(“Enter username:”)
switch username:
case “Ann”:
print(“Welcome Ann. You’re awesome.”)
case “Bob”
print(“Welcome Bob. You’re the boss.”)
case “Cat”:
print(“Welcome Cat. You’re class.”)
case “Dee”:
print(“Welcome Dee. You’re dynamite”)
default:
print(“Who are you?”)
endswitch
So why use a switch instead of a bunch of Ifs? Well, we could but it would be messy when compared to the switch statement. We could do it a bit like this:
username = input(“Enter username:”)
if username = “Ann”:
print(“Welcome Ann. You’re awesome.”)
elseif username = “Bob”
print(“Welcome Bob. You’re the boss.”)
else if username = “Cat”:
print(“Welcome Cat. You’re class.”)
elseif username = “Dee”:
print(“Welcome Dee. You’re dynamite”)
else
print(“Who are you?”)
which looks pretty much the same but to the computer there is a lot of stop and go compared to the switch. The switch tells the computer it’s going to be comparing a variable (and only one variable) to something in a list. It is not expecting to have to do anything more complicated. Switches are good when comparing an input to a know list of options.
Looping Code
With Ifs and Switches under our belt now we turn to the next most important part of repeating code over and over until we say stop. Repeating or looping code is what computers are absolutely brilliant at and will happily do the same process over and over without a word of complaint (well – we can accidentally force the computer to over heat and shut down but that’s when it goes wrong). Before we look at the loops there is something important to remember – a computer is very fast – so fast you won’t be able to tell. So if you write a program where a block moves 10 steps to the left then 10 steps to the right you won’t see it. If you remember the very first subject was the CPU and clock speeds in the gigahertzs that is 1, 000, 000, 000 cycles per second: it’s fast. Loops are very fast and if not controlled correctly can run out of control.
Good. There are three loops: For, Do and While (it’s actually Do While but we’ll get to that). Normally at the GCSE level you get at best some of the topic and then not the whole truth of the topic but when it comes to loops they are the three you will need to know if you just do the GCSE or decide a career in computer coding. So let’s have a look.
For Loop
How many times? For times? The For loop is the loop that can count as it only runs for a predetermined number of times before stopped and moving on to the next line of code (the other two loops can’t count). There are three parts of a for loop: 1) start value, 2) stop value, 3) step count (the default is 1). How to set the start, stop and step values varies in the programming language that is being used. I’ll give two examples to show how they differ
For Loop – Python
for i in range(1, 6):
print(i)
1
2
3
4
5
Start value: 1
Stop value: 6
Setting the count: 1 (default)
You may notice that the stop value is 6 but only 5 things are printed out. This is one of the key differences between humans and computers. Computers are counting machines at their heart. For the above For Loop I’m asking the computer to start at one and then end BEFORE 6 as the check is ‘If number = 6 then stop’. Remember if you want to get the computer to loop the number of times you’re after then add one.
Do Loop and While Loop
The two other loops are very similar and often confused in the use and the difference. The loops are so similar that python doesn’t even have a Do loop but use a modified While loop. Anyway both loops don’t count like the For loop. They will happily run forever as the only way they stop is when the condition that keeps it going is no longer true (remember we can set a condition when the condition because true anyway let’s move on).
Both loops state :
while this is true
do this
e.g.
while 1 == 1 then
print(“infinity loop people!!!”)
This is the biggest danger with a while or a do loop – unless you have a way of stopping them the computer will run it forever. In the above print is not an expensive function. Imagine we make it more expensive in terms of computing resource
while 1 == 1 then
create file (“hello world.txt)
This is a problem but not the end of the world. What would be the end of the world or certainly bad …
while 1 == 1 then
spend £1 from bank account
So. Always have a way to make sure the loop stops. We do this by changing the

