Practical Examples (GCSE Pseudocode & Python)

Part of Selection (IF Statements) · Section 7 of 10

Study NotesUnit: 3.2 ProgrammingGCSE

This study notes covers Practical Examples (GCSE Pseudocode & Python) within Selection (IF Statements) for GCSE Computer Science. Revise Selection (IF Statements) in 3.2 Programming for GCSE Computer Science with 15 exam-style questions and 8 flashcards. This topic shows up very often in GCSE exams, so students should be able to explain it clearly, not just recognise the term. It is section 7 of 10 in this topic. Use this study notes to connect the idea to the wider topic before moving on to questions and flashcards.

Practical Examples (GCSE Pseudocode & Python)

Example 1: Grade Calculator

GCSE Pseudocode:

score = input("Enter score: ")
if score >= 70 then
    grade = "A"
elseif score >= 60 then
    grade = "B"
elseif score >= 50 then
    grade = "C"
elseif score >= 40 then
    grade = "D"
else
    grade = "U"
endif
print("Grade: " + grade)

Python Equivalent:

score = int(input("Enter score: "))
if score >= 70:
    grade = "A"
elif score >= 60:
    grade = "B"
elif score >= 50:
    grade = "C"
elif score >= 40:
    grade = "D"
else:
    grade = "U"
print("Grade:", grade)

Example 2: Login Validation

username = input("Username: ")
password = input("Password: ")
if username == "admin" AND password == "secret123" then
    print("Access granted")
    loggedIn = true
else
    print("Access denied")
    loggedIn = false
endif

Practice questions for Selection (IF Statements)

Which programming construct is used to make a decision based on a condition?

  • A. FOR loop
  • B. IF statement
  • C. WHILE loop
  • D. Function definition
1 markfoundation

Explain the difference between using ELSEIF and using nested IF statements to test multiple conditions.

3 marksstandard

Quick recall flashcards

When use ELSEIF?
When you have multiple conditions to check
When use SWITCH?
Comparing one variable against many specific values

15 questions on Selection (IF Statements) — practise free

Instant marking, adaptive difficulty and spaced-repetition flashcards — all aligned to your exam board.

Start revising free →