GCSE · Computer Science · Edexcel · Spec 1CP2

Converting algorithms to programs

Two lines, one job: PRINT "Hello" and print("Hello"). So why can a computer run only one of them?

Computer Science · Algorithms

One algorithm, two spellings

Step through the name algorithm. Each pseudocode line is followed straight away by its Python line.

At every pair of lines, ask: what is on the screen, and what does name hold? Will the Python ever give a different answer from the pseudocode?

1 pseudocode | PRINT "What is your name"
2 python | print("What is your name")
3 pseudocode | INPUT name
4 python | name = input()
5 pseudocode | PRINT "Hello" + name
6 python | print(f"Hello {name}")

Variables

name=(nothing yet)

Output

What is your name

Step 1: Read the pseudocode like a person would: output the question. The screen shows What is your name, and name holds nothing yet.

1 / 6

Press Next. Watch the Output box and the Variables panel: they only change when the logic does.

Step 1 of 6: Read the pseudocode like a person would: output the question. The screen shows What is your name, and name holds nothing yet..

Four ways to express a solution

Which one can a computer actually follow?

Tick every property each one has, then check. Dashed cells show where your idea and the truth differ.

Written description
Flow chart
Pseudocode
Python program

Your turn: finish the conversion

A ticket shop, from plan to Python

A shop sells tickets that all cost the same. The program must work out the total cost, ask how many tickets someone wants, and say whether a group discount applies. First understand the problem, then pick out what matters (the fixed price and the number of tickets), then decompose it: a constant, a function, then the main steps. Choose the missing Python lines.

  1. TICKET_PRICE = 4Constants go first: the price never changes while the program runs.
  2. missing step
Which line is step 2?

Find the slip

The pseudocode habit that Python rejects

A student converts this pseudocode: INPUT a score; IF the score is more than 50 THEN PRINT "Pass", ELSE PRINT "Try again". Every line of their Python is correct except one. Which line keeps a pseudocode habit that Python will not accept?

The student's Python — which line goes wrong?

What do you think?

One algorithm, a few tempting mistakes

The same algorithm is written in Python and in another programming language. The two programs look very different.

Which idea is closest to what you think right now?
How sure are you?

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

Same steps, new spelling: how logic written in plain words becomes code a computer can run.

What you need to know

  • An algorithm is a set of step-by-step instructions, in a logical order, that solves a problem: the logic, not any one language.
  • A computer program implements an algorithm by writing it in a programming language the computer can interpret.
  • For a computer to follow an algorithm, the instructions must be converted into a computer program.
  • Have a goMaya insists an algorithm and a computer program are just two names for the same thing. Which of the two has to be written in a language the computer can interpret?

    The program.

    The algorithm is the logic of the solution. The program is that logic implemented in a language, which is why converting is needed.

  • You can write an algorithm as a written description, a flow chart or pseudocode, and each can be converted into a program.
  • Pseudocode has no strict syntax rules, so it cannot run directly: it must be translated into a real language such as Python.
  • A programming language has very strict syntax rules, and they must be followed for the computer to execute correctly.
  • Have a goYour pseudocode is neat, tidy and crystal clear. Can a computer run it directly? Say why or why not.

    No. It has no strict syntax rules.

    Neatness does not change the fact that pseudocode must be translated into a real programming language before it can be executed.

  • Converting means writing each step in the chosen language's syntax. Python keywords, for example, are written in lower case.
  • Pseudocode keywords are often capitalised: INPUT, PRINT, WHILE, FOR, and IF, THEN and ELSE.
  • One algorithm can become many programs in different languages. They look different, but the logic stays the same.
  • Have a goTwo people write the same algorithm in two different languages and the programs look nothing alike. What do you expect to match?

    The logic of the algorithm.

    Each language has its own syntax rules, so the code differs, but the logic stays the same.

  • Before converting, understand the problem, abstract the key information and, usually, decompose it into smaller steps.

The big picture

An algorithm is the step-by-step logic of a solution; a program is that logic written in a programming language with strict syntax. Converting means rewriting every step in the chosen language's syntax. The words change, the logic does not. Pseudocode has no strict syntax, so it must be translated before a computer can run it.

Key points

1An algorithm is the logic of a solution; a computer program is that logic written in a programming language the computer can interpret.
2A written description, a flow chart and pseudocode can each be converted into a program.
3Pseudocode has no strict syntax rules and cannot be run directly; a programming language has very strict syntax rules.
4Converting rewrites every step in the language's syntax; the logic of the algorithm stays the same.
5Before converting: understand the problem, abstract the key information and usually decompose it into smaller steps.

Worked example

Problem

Convert this pseudocode into Python. It keeps asking for a guess until the player types 7. In order: PRINT "Guess the number"; INPUT guess; WHILE guess is not 7, do PRINT "Wrong, try again" and INPUT guess again; finally PRINT "Correct".

⚠ Watch out

Treating pseudocode as a sloppy program that will run once it is tidied. It has no strict syntax rules, so it must be translated into a real programming language first. The logic carries over; the pseudocode itself does not.

🧠

Memory hook

Same steps, new spelling: the logic never moves, only the syntax does.

✓

Check yourself

Pick any pseudocode line from this lesson and say its Python version aloud. Then say what changed in the line and what did not change in the logic.

Flashcards

(13)
What is an algorithm?
A set of step-by-step instructions, followed in a logical order, to solve a problem. It describes the logic of a solution.
What is a computer program?
A way of implementing an algorithm by writing it in a programming language the computer can interpret and execute.
Why must an algorithm be converted before a computer can follow it?
A computer follows a computer program, so the instructions must be converted into one.
Name three ways to represent an algorithm.
A written description (readable human language), a flow chart (arrows and shapes) or pseudocode (syntax independent of any one language).
Can a computer execute pseudocode directly?
No. It has no strict syntax rules and must be translated into a real language such as Python first.
What is special about a programming language's syntax?
It has very strict syntax rules that must be followed for the computer to execute the instructions correctly.
One algorithm, two programs in different languages. What differs and what stays?
The syntax and look of the code differ. The logic of the algorithm stays the same.
Pseudocode: what do INPUT and PRINT mean?
INPUT: a user is expected to input something. PRINT: information will be output to the screen.
Pseudocode: what does WHILE do?
It starts an iteration that continues as long as its condition is met.
Pseudocode: what does FOR do?
It is a count-controlled iteration that does something a set number of times.
Pseudocode: what do IF, THEN and ELSE do?
Together they make a selection decision.
How are Python keywords written?
In lower case, whereas pseudocode keywords are often capitalised.
What should you do before converting an algorithm?
Understand the problem, abstract the most important information and, in most cases, decompose it into smaller steps.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More Edexcel GCSE Computer Science topics

See the full Edexcel Computer Science curriculum →

How this lesson was checked. This Edexcel GCSE Computer Science (specification 1CP2)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 21 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.