Session XP: 0
1CP2 P1Edexcel GCSE Computing · 1CP2 Paper 1 (Programming)

Operators and String Handling

Arithmetic, relational and Boolean operators. String functions: length, substring, upper, lower, charAt. Core Paper 1 skills.

Best score
Last attempt
Best attempt progress
0
XP earned
Watch first
Craig n DaveOperators in pseudocode
Craig n DaveString handling in pseudocode
Reference & Examples

Arithmetic operators

  • + addition, - subtraction, * multiplication, / division.
  • MOD — remainder after integer division. 7 MOD 3 = 1. 10 MOD 2 = 0 (even test).
  • DIV — integer (whole-number) division. 7 DIV 3 = 2 (discard remainder).
  • ^ or ** — exponentiation (power). 2^3 = 8.
  • Precedence (BIDMAS): brackets, powers, then * / MOD DIV, then + -.

Relational (comparison) operators

  • == equal to. != not equal to.
  • < less than. > greater than.
  • <= less than or equal to. >= greater than or equal to.
  • Used in IF conditions and WHILE conditions.
  • Return Boolean value: True or False.
  • Example: IF score >= 50 THEN

Boolean (logical) operators

  • AND — both conditions must be True. (x > 0) AND (x < 10)
  • OR — at least one condition must be True. (grade == "A") OR (grade == "B")
  • NOT — reverses Boolean. NOT (x == 0) is True when x is not 0.
  • Combined: IF (age >= 18) AND (hasID == True) THEN
  • Truth table: AND is True only if BOTH True. OR is True if EITHER is True.

String operations

  • LEN(str) — returns number of characters. LEN("hello") = 5.
  • SUBSTRING(str, start, length) — extract part of string. SUBSTRING("hello", 0, 3) = "hel".
  • UPPER(str) — converts to uppercase. UPPER("hello") = "HELLO".
  • LOWER(str) — converts to lowercase.
  • str[i] — access character at index i (0-indexed). "hello"[0] = "h".
  • String concatenation: + operator. "Hello" + " " + "World" = "Hello World".
String handling examples (Edexcel pseudocode)
name = "Ander"
PRINT LEN(name)          // Output: 5
PRINT SUBSTRING(name, 0, 3)   // Output: "And"
PRINT UPPER(name)        // Output: "ANDER"
PRINT name[0]            // Output: "A"

// Checking first character
IF UPPER(name[0]) == "A" THEN
    PRINT "Name starts with A"
END IF

// String concatenation
greeting = "Hello, " + name + "!"
PRINT greeting           // Output: "Hello, Ander!"
MOD and DIV examples
// MOD: remainder
PRINT 10 MOD 3     // Output: 1
PRINT 8 MOD 2      // Output: 0  (so 8 is even)

// DIV: integer division
PRINT 17 DIV 5     // Output: 3
PRINT 17 MOD 5     // Output: 2  (17 = 3*5 + 2)

// Test if number is even
IF num MOD 2 == 0 THEN
    PRINT "Even"
ELSE
    PRINT "Odd"
END IF
Exam practice — 5 questions · 12 marks · 1CP2 Paper 1 style
⚡ Write your pseudocode or answer — the AI marks against the Edexcel 1CP2 Paper 1 mark scheme.
1 markMOD operator1CP2 Paper 1

What is the result of 17 MOD 5?

A 3
B 2
C 5
D 0
1 markString length1CP2 Paper 1

What does LEN("Computing") return?

A 8
B 9
C 10
D 7
3 marksSubstring extraction1CP2 Paper 1

A variable word is assigned the value "Python". Write pseudocode to: (a) print the first 3 characters, (b) print the string in uppercase, (c) print the last character. (3 marks)

Hint: (a) SUBSTRING(str, start, length). (b) UPPER(str). (c) Last index = LEN(str) - 1 because 0-indexed.
+30 XP
4 marksOperators in conditions1CP2 Paper 1

Write pseudocode for a program that: asks the user for a number, then prints "Fizz" if divisible by 3, "Buzz" if divisible by 5, "FizzBuzz" if divisible by both, otherwise prints the number. (4 marks)

Hint: Check FizzBuzz FIRST (both conditions) before checking individual ones. Use MOD to test divisibility.
+40 XP
1 markBoolean operator1CP2 Paper 1

What is the result of: (5 > 3) AND (10 < 8)?

A True
B False
C Error
D 0

Module complete! 🎉

Score loading...

+10 XP