ScholaFly

CS10-05 Computer Science Watch

Pseudocode

Watch on YouTube

In this lesson

Pseudocode: how to read a short algorithm written in pseudocode and say what it does, with worked examples and the mistakes examiners report. AQA 8525, Edexcel 1CP2 and OCR J277 GCSE. Algorithms 5 of 9. More at https://scholafly.com

By the end: Read a short algorithm written in pseudocode and say what it does, then complete, correct and write short algorithms in pseudocode using clear keywords for input, output, assignment, decisions and loops, with indentation that shows what belongs inside what.

What it covers

  1. 0:00 Intro: pseudocode
  2. 0:40 What pseudocode
  3. 1:59 Read: six lines
  4. 3:24 Complete: fill the gaps
  5. 5:49 Write: from a paragraph

Key words

About this video

Pseudocode | GCSE Computer Science | CS10-05

Pseudocode: how to read a short algorithm written in pseudocode and say what it does, with worked examples and the mistakes examiners report.
AQA 8525, Edexcel 1CP2 and OCR J277 GCSE. Algorithms 5 of 9.
More at https://scholafly.com

Watch first: CS10-03 - https://youtu.be/uvNHZSc6E0E
Video code: CS10-05 (search "ScholaFly CS10-05")

#GCSEComputerScience #Algorithms #Pseudocode

For teachers
This GCSE Computer Science lesson teaches pseudocode. By the end, students should be able to read a short algorithm written in pseudocode and say what it does, then complete, correct and write short algorithms in pseudocode using clear keywords for input, output, assignment, decisions and loops, with indentation that shows what belongs inside what. It works through four worked examples and the mistakes examiners report.

Exam board specification references:
AQA 8525
- 3.1.1
Edexcel 1CP2
- 1.2.1
OCR J277
- 2.1.2

Read the transcript

A film starts as a script, and a program starts as a written plan of its steps. How strict should that plan be? Plain English feels easiest and real code feels safest. But loose English can be read two ways, and real code is already the program, not a plan for it. A good plan works like a film script: precise enough for anyone to follow, but not yet the real thing.

Pseudocode is a way of writing an algorithm that looks like code but is not tied to any one programming language, so a person can read it and check it. A few keywords carry the structure. INPUT takes data in, and OUTPUT sends it out. An equals sign stores a value in a variable, a named place that holds data. IF, ELSE and ENDIF make a decision. WHILE and ENDWHILE repeat for as long as something is true. FOR, TO and NEXT repeat a counted number of times. Every line inside an IF or a loop is indented, pushed in from the left, and every IF, WHILE and FOR has its end marker. That is how a reader sees what belongs inside what. Each course prints its exam questions in a style of its own. This video uses one neutral style, and the video on which notation to answer in sets the courses' styles side by side.

Reading comes before writing, so start with six lines. Total is set to nought. For i from one to five, input a number and add it to total. Next i. Then output total. In one sentence, what does this algorithm do? It adds up five values typed in and displays their sum. Four kinds of line are in there: input, a value stored, a counted loop and output. The indentation shows two lines inside the loop, which is why those two run five times. Here are the same six lines with every indent removed and the NEXT line gone. Without indents or NEXT, which lines are inside the loop? There is no way to tell. The loop could hold one line or all of them, which is why every FOR needs its NEXT and every line inside is indented.

Completing an algorithm means filling its gaps in the style it is already written in. This one should output pass for a mark of fifty or more, and fail otherwise. It has two gaps: one in the IF line, and one on the line before fail. What fills the gap in the IF line, and what fills the gap before fail? Greater than or equal to goes in the IF line. ELSE goes before fail, so every other value lands there. This one is meant to ask for a password over and over, stopping when letmein is typed. It never stops. Which line is missing from this password loop, and where does it go? INPUT password, inside the loop, straight after the line that asks. Without it the password never changes, so the WHILE condition is never false. A check for any loop: draw a box round its body and ask what must happen on every pass. Here, the user must be asked and must answer, so both lines sit inside the box. This is the password task from the video Flowcharts. The arrow back up to input password is this loop, and the input box sits inside it, the same way the INPUT line now does. One examiner's report, on a question in a different context, says: "A pseudo-code guide is one of the resources available and students should be prepared to answer questions in each of the three ways." The three are pseudocode, program code and flowcharts. The fix is practice in each one. Pseudocode is a skill of its own, so write it, not only code.

Writing from a description is the last skill. Here is a paragraph answer: ask ten people their age and count the ones who are eighteen or over and then say the count. Every idea is in there, and none of the structure is. Write it as pseudocode instead: ask for the ages of ten people, and output how many are eighteen or over. Indent the lines the loop holds, and the lines the IF holds. Write it, with the loop's lines and the IF's lines indented, before mine appears. Count starts at nought. A FOR loop runs ten times, and each time it inputs an age. Inside the loop, an IF checks whether that age is eighteen or more, and if so, adds one to count. After NEXT, outside the loop, the count is output once. The IF is indented inside the loop, and its own line is indented again, so each level is visible. If your capitals or brackets differ from these, that is fine. Pseudocode is judged on its logic, and one course's specification says it "uses imprecise English language statements and does not require any strict programming syntax." Clear and consistent still matters, because a person has to follow it: one step per line, a keyword on every decision and loop, and indentation that shows what is inside. A second report notes: "Candidates appear to be getting more confident at answering simple programming or pseudocode questions such as this." The habit behind that confidence is the one in this video: read, complete, correct and write short algorithms, a few at a time.

Read, complete, correct and write: one question for each, in that order. Read this: INPUT number, then OUTPUT number times two. What does it do? It doubles whatever value is typed in, and displays the result. Now fill the gap: IF it rains THEN take a coat, gap, leave the coat, ENDIF. ELSE. Without it, both lines run whenever it rains. Here's a broken one: INPUT sits above the WHILE in an asking loop. What goes wrong? It asks once and never again, so the loop can run forever. The INPUT belongs inside the loop. One more, the film script: what must pseudocode be, so a person can check the plan? Clear and consistent, and not tied to any one language. One step per line, keywords on decisions and loops, and indentation showing what is inside what.

That brings this video onto the chapter list. Being solid on it is what the thumbs up records, and the video drops off your rewatch pile; no thumbs up means it is one to return to. If it still feels clumsy, save it. Nobody writes tidy pseudocode the first time, and the third or fourth algorithm comes out far neater than the first.

Next in the chapter: Sequence, selection and iteration in an algorithm, the three building blocks inside every one of these. Hopefully that's next in your feed, but if not, search for ScholaFly C S ten, oh six.

Every other video is on scholafly.com too, easy to search by video code or by keyword. Whatever you're revising, go there and have a look, or, watch the next video.

Related terms

For: AQA GCSE 8525, Edexcel GCSE 1CP2, OCR GCSE J277

On the specification

BoardSpecStatement
AQA GCSE 85253.1.1Representing algorithms
Edexcel GCSE 1CP21.2.1Algorithms
OCR GCSE J2772.1.2Designing, creating and refining algorithms
For teachers

This GCSE Computer Science lesson teaches pseudocode. By the end, students should be able to read a short algorithm written in pseudocode and say what it does, then complete, correct and write short algorithms in pseudocode using clear keywords for input, output, assignment, decisions and loops, with indentation that shows what belongs inside what. It works through four worked examples and the mistakes examiners report.