From Plan to Code 🛠️
How to write the logic for Scenario 1 (Library Age Limit 5-18)
The Rule: If the age is between 5 and 18 (inclusive), they can join. Otherwise, show an error.
Pseudocode
Cambridge IGCSE Style
OUTPUT "Please enter your age:"
INPUT UserAge
IF UserAge >= 5 AND UserAge <= 18
THEN
OUTPUT "Welcome to the library!"
ELSE
OUTPUT "Sorry, invalid age."
ENDIF
Python 3
Actual Implementation
age = int(input("Enter age: "))
if age >= 5 and age <= 18:
print("Welcome to the library!")
else:
print("Sorry, invalid age.")
Key Differences to Remember:
- Assignment: In Pseudocode we use
← (e.g., Total ← 0), but in Python we use =.
- Output: Pseudocode uses
OUTPUT, Python uses print().
- Ending Blocks: Pseudocode must end an IF statement with
ENDIF. Python uses indentation (tabs) and colons : instead.
- Case: Pseudocode keywords are written in UPPERCASE for clarity in exams.
Mastering this layout will help you ace your Paper 2 exam! 📝✨