Skip to topic
    ← Back to course topics

    Operators — Edexcel GCSE Computer Science

    Verified courseTeaching note checked against the official specification.

    Operators explained

    Operators covers 3 specification points, including Be able to write programs that use arithmetic… and Be able to write programs that use relational….

    Read the full explanation

    Open a point below for its explanation and revision guidance.

    6.5.1 be able to write programs that use arithmetic operators (addition, subtraction, division, multiplication, modulus, integer division, exponentiation)

    This criterion requires you to write working program code, not merely name operators. In a language such as Python, addition combines values (total = price + tax), subtraction finds a difference (change = paid - cost), multiplication scales (area = width * height) and division produces a quotient (mean = total / count). Modulus returns the remainder (remainder = value % 7), which is useful for testing divisibility or wrapping values. Integer division discards the fractional part (whole = total // count), giving how many whole times one number fits into another. Exponentiation raises a base to a power (area = side ** 2 for a square, volume = side ** 3 for a cube). Choose the operator that matches the required output, apply it to the correct operands, and check the result with a test value.

    6.5.2 be able to write programs that use relational operators (equal to, less than, greater than, not equal to, less than or equal to, greater than or equal to)

    This criterion requires you to write program code that compares values using relational operators, which produce a Boolean result of true or false. In a language such as Python, equal to is written with two equals signs (score == 10), not equal to uses an exclamation mark before the equals sign (score != 10), less than and greater than use the angle brackets (score < 10 and score > 10), and the inclusive comparisons combine an angle bracket with an equals sign (score <= 10 and score >= 10). These results commonly control selection or iteration, for example if temperature >= 100: then sound an alarm, or while count < limit: to repeat a loop. Choose the operator that matches the boundary described, place the values in the correct order, and test with values just below, exactly on and just above the boundary.

    6.5.3 be able to write programs that use logical operators (AND, OR, NOT)

    This criterion requires you to write working program code, not merely to describe operators. In a language such as Python, AND, OR and NOT combine or invert Boolean expressions so a single condition can test several facts. AND is true only when both operands are true; OR is true when at least one operand is true; NOT reverses a Boolean value. For example, a program might admit a pupil when age >= 11 AND age <= 16, warn when score < 40 OR attendance < 80, and print a message only when NOT submitted. You must choose the correct operator for the intended logic, place it between valid Boolean expressions, and test the program with inputs that make each combined condition true and false. Assessment asks you to select or write code whose logic matches a stated rule, so trace each operand before deciding.

    Your focus

    1. Identify the arithmetic operator that produces a required result for a given problem.
    2. Write a complete program statement using addition, subtraction, multiplication, division, modulus, integer division or exponentiation as appropriate.
    3. Evaluate a short arithmetic expression correctly and justify the operator chosen.
    Show all 9 objectives
    1. Identify the relational operator that matches a described comparison, including whether the boundary is included.
    2. Write a complete comparison using equal to, not equal to, less than, greater than, less than or equal to or greater than or equal to.
    3. Evaluate a comparison with sample values and state whether the result is true or false.
    4. Select AND, OR or NOT to express a stated logical rule in code.
    5. Write a condition that combines two comparisons correctly using AND or OR.
    6. Test a combined condition with inputs that make it true and false.

    Operators exam tips

    Marking Points
    • Selects the correct arithmetic operator for a stated purpose, for example addition to combine two quantities or multiplication to scale a value.
    • Writes a complete expression in which every operator has both operands, such as total = price + tax or area = side ** 2.
    • Distinguishes modulus from integer division: modulus yields the remainder, while integer division yields the number of whole times one value fits into another.
    • Uses exponentiation for powers, for example side ** 2 for a square's area and side ** 3 for a cube's volume, rather than repeated multiplication written incorrectly.
    • Applies the correct order of operations or uses brackets so that a compound expression evaluates as intended.
    • Tests the program with sample inputs and confirms the output matches a hand-calculated result.
    • Selects the relational operator that matches a stated comparison, for example greater than or equal to when a value on the boundary must also be accepted.
    • Writes a complete comparison with a value on each side of the operator, such as score >= 50 or name == "Ada".
    • Uses two equals signs for equality testing and reserves a single equals sign for assignment.
    • Uses the not-equal operator when a condition must be false for the tested value.
    • Places the operands in the correct order so the comparison means what is intended, for example age < 18 rather than 18 < age when testing for a minor.
    • Uses the Boolean result correctly in a selection or loop, for example as the condition of an if statement.
    • AND returns true only when both operands are true, so a rule requiring two conditions to hold together must use AND.
    • OR returns true when at least one operand is true, so a rule allowing either condition to qualify must use OR.
    • NOT inverts a single Boolean value or expression, turning true into false and false into true.
    • Each operand of AND or OR must itself be a Boolean expression, such as a comparison, not a bare value.
    • Correct code applies the operator to the intended conditions and produces the outcome stated in the question for every tested input.
    Examiner Tips
    • 💡Read the question's required output first, then choose the operator whose result matches that output rather than the operator that looks familiar.
    • 💡Trace a short expression with small numbers by hand before selecting an answer, so the predicted result can be compared with each option.
    • 💡Check each candidate expression for completeness: every operator must have a value on both its left and its right.
    • 💡When two options differ only in one operator, evaluate both with the same sample numbers and compare the results.
    • 💡Underline the boundary words in the question, such as 'at least' or 'fewer than', because they decide whether the inclusive form is needed.
    • 💡Test each candidate comparison with three values: one below the boundary, the boundary value itself and one above it.
    • 💡Check the direction of the comparison by substituting a simple number and reading the result as a sentence.
    • 💡Eliminate options that use a single equals sign for a comparison, since that is an assignment rather than a test.
    • 💡Rewrite the stated rule in words as 'both', 'either' or 'not' before choosing the operator.
    • 💡Trace one input that should pass and one that should fail through the full condition to confirm the operator.
    • 💡Check that each side of AND or OR is a complete comparison rather than a single value.
    Common Mistakes
    • Confusing modulus with integer division: the learner expects the whole-number quotient from the modulus operator. Correction: modulus returns the remainder, so 17 % 5 gives 2, while integer division 17 // 5 gives 3.
    • Writing an expression in which an operator has only one operand, which is a syntax error. Correction: every operator needs a value on each side, so write the full expression with both operands present.
    • Assuming ordinary division always produces a whole number. Correction: ordinary division can produce a fractional result, so use integer division when a whole-number quotient is required.
    • Using exponentiation when simple multiplication is intended, or vice versa. Correction: match the operator to the mathematical meaning, using exponentiation only for raising a base to a power.
    • Using a single equals sign where a comparison is required. Correction: a single equals sign assigns a value, so use two equals signs to test equality.
    • Reversing the operands so the comparison means the opposite of what is intended. Correction: read the comparison aloud in words and check that the subject and the limit are in the order described.
    • Treating less than as including the boundary value. Correction: less than excludes the boundary, so use less than or equal to when the boundary must be accepted.
    • Assuming a comparison returns a number rather than a Boolean. Correction: relational operators produce true or false, which is then used by the surrounding selection or loop.
    • Using AND when the rule means either condition is enough; correct this by using OR so one true operand makes the whole condition true.
    • Using OR when both conditions must hold; correct this by using AND so the result is true only when both operands are true.
    • Placing NOT before a comparison without checking the resulting logic; correct this by tracing the inverted value and confirming it matches the intended rule.