πŸ” Topic 7+8 – Python vs Pseudocode Sheet

πŸ“šΒ IGCSE Computer Science 0478


πŸ§‘πŸ»β€πŸ’» Programming in Paper 2

In IGCSE Computer Science, especially in Paper 2 (Algorithm and Programming), students are expected to write code-like logic using Pseudocode. But what is Pseudocode, and why is it so important?

Pseudocode is a simplified way of writing programming logic that doesn't follow the strict rules of any particular programming language. It uses clear, structured English-like commands to describe what a program should do.

πŸ”€ Why Pseudocode?

πŸ”Ή IGCSE Exam Requirement: In Paper 2, most questions must be answered in pseudocode. Only the final question allows you to use Python or Pseudocode.

πŸ”Ή Language-Independent Thinking: Pseudocode helps you understand the core of how algorithms work: loops, conditionals, data structures.

In short, pseudocode is your stepping stone from thinking like a programmer to writing real code.


πŸ“ How to Use This Cheat Sheet

The Pseudocode vs Python cheat sheet is designed to help you bridge the gap between algorithm logic and real code. It includes:

  1. πŸ”€ The pseudocode version (as per IGCSE)
  2. 🐍 The equivalent Python syntax
  3. πŸ’‘ A Description + Tips and Examples

Use this sheet when practicing exam questions, revising syntax, or converting pseudocode into Python, especially useful for the final question in Paper 2. It’s also a great for quickly spotting the differences and similarities between the two so you can confidently switch between them in your learning and exams.

Concept Pseudocode Python Notes / Examples
Data Types INTEGER, REAL, CHAR, BOOLEAN int, float, str, bool INTEGER ← 3, REAL ← 3.0, CHAR = "B" ,float = 5.4, bool = True
Comment // this is a comment # this is a comment Use comments to explain code. Python uses #
Declaration DECLARE Number1: INTEGER, DECLARE Name: STRING # no declarations ( only as comment) Use DECLARE in pseudocode. Declarations in Python don’t exist.
Assignment name ← "John", number ← 123 name = "John", number = 123 ← in pseudocode is assignment
Constants CONSTANT Pi ← 3.14 PI = 3.14 # IN CAPS Python doesn't enforce constants but uses CAPS
Input INPUT "Your name is?: ", Name name = input("Your name is?: ") Asking user for a value that we store in a variable
Output OUTPUT "Hello" Name print("Hello", name) For printing out on the screen
If Statements `IF x > 5 THEN
OUPTUT "X is bigger than 5"
ELSE
OUPTUT "X is smaller or equal to 5"
ENDIF` `if x > 5:
print("X is bigger than 5")
else:
print("X is smaller or equal to 5")` Pseudocode has THEN, Python uses :
Elif / Else If
While Loops `DECLARE answer : CHAR
INPUT answer
WHILE answer β‰  "y"
INPUT answer
ENDWHILE`
`answer = input("Start? ")
while answer != "y":
answer = input("Start? ")`
This loop executes the code inside based on a condition
For Loops FOR i ← 1 TO 10 STEP 1,NEXT i for i in range(1, 11, 1): `for i in range(1, 4): # Loops 1 to 3
print(i)`
Like While Loop but amount of time it repeats known beforehand. Python range excludes last number. You can loop from a number to another number with step of 1, 2 etc. This is for repeating a certain code
Modulus / Quotient Num1 ← 2 MOD 2, Num2 ← 9 DIV 2,
`IF Num3 MOD 2 = 0 THEN
OUTPUT "Number 3 is even"
ELSE
OUTPUT "Number 3 is odd"
ENDIF`
num1 = 9 % 2, num2 = 9 // 2,`if num3 % 2 == 0:
print("Number 3 is even")
else:
print("Number 3 is odd")` MOD gives remainder of division, DIVgives quotient of division.
Functions `FUNCTION ToFahr(celsius : REAL) RETURNS REAL
RETURN (9/5) * celsius + 32
ENDFUNCTION` `def toFahr(celsius):
return (9/5)*celsius + 32`
Use def in Python, RETURN/return to send value back
Procedures `PROCEDURE Hello()
OUTPUT "Hi"
ENDPROCEDURE` `def hello():
print("Hi")` Same as function but without returning a value back
Array Declaration DECLARE Jobs: ARRAY[1:3] OF STRING # declare jobs list of strings
Array Assignment Jobs ← ["Engineer", "Doctor", "Banker"], Jobs[4] ← ["Scientist"] jobs = ["Engineer", "Doctor", "Banker"] arrays in Python are called lists and can are dynamic (no predetermined size)
2D Arrays DECLARE grid: ARRAY[0:2, 0:2] OF INTEGER
grid = [[0,1],[2,3]]
Relational Operators =, <>, <, >, <=, >= ==, !=, <, >, <=, >= Note: = in pseudocode is comparison, not assignment
Repeat Until `X ← 1
REPEAT
OUPUT X
UNTIL X = 10` x = 1
`while True:
print(x)
if x == 10: break` Use infinite loop + condition to break in Python. Repeat Until at least loops once unlike a While Loop that can also loop 0 times.