Back to Operators

Oak National Academy

Lessons written by expert teachers in England, each with slides, a video and quizzes.

Their topic:
Programming: selection
For your topic:
Operators · Computer Science - 4CP0

Use these lessons alongside our lesson note, which covers your syllabus in full.

What this covers in your syllabus

3 lessons from Oak National Academy

Lesson 1 of 3 · GCSE level, ages 14 to 16

Arithmetic operators

By the end: I can use a variety of arithmetic operators in a program.

Key learning points

  1. Arithmetic expressions are used to calculate values.
  2. Arithmetic expressions can be used in selection statements. Expressions either return as True or False.
  3. In real division there is no remainder because the entire value is divided.
  4. Integer division is when any remainder of a division is discarded.
  5. Modulo division (MOD) will return only the remainder of a division.

Keywords

operator
a symbol or word that instructs the computer to perform a specific calculation or action
arithetic expression
an expression that results in a numeric value
integer division
sometimes known as floor division, is when any remainder of a division is discarded
modulo division
an operation that gives you the remainder when one number is divided by another

A common mistake

Mistake: Just like addition, subtraction and multiplication there is only one type of division in programming.

In fact: There are three types of division in programming; real, integer and modulo division. Each deal with remainder values differently and will be useful in different ways in programming.

Check what you learned

From Oak National Academy's exit quiz. Choose every answer that is right.

What is an arithmetic operator?
What is the result of 10 - 2 + 2 * 5
What does the // symbol represent?
What does the modulo operator (%) return?

A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0. Read the licence

Lesson 2 of 3 · GCSE level, ages 14 to 16

Logical operators

By the end: I can use logical operators to build more complex selection statements.

Key learning points

  1. Logical operators are often used when you need to evaluate multiple relational expressions to return a single value.
  2. Logical expressions return as either True or False. The three basic logical operators are and, or, and not.
  3. Logical expressions can be used in selection statements.

Keywords

logical expression
an expression that combines relational and logical operators
selection
used when there is more than one possible path for a program to follow

A common mistake

Mistake: A logical expression can only check one value.

In fact: Logical expressions can combine relational and logical operators to check multiple values or inputs.

Check what you learned

From Oak National Academy's exit quiz. Choose every answer that is right.

What is the purpose of logical operators in programming?
Which of the following is True when both conditions are True?
Which logical operator is used to reverse the result of a condition?
What will be displayed if the user inputs "king" for value and "hearts" for suit? ``` if value == "king" and suit == "hearts": print("Match") else: print("Not a match") ```

A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0. Read the licence

Lesson 3 of 3 · GCSE level, ages 14 to 16

Relational operators

By the end: I can use relational operators as part of selection statements.

Key learning points

  1. Relational operators are used to compare values in expressions.
  2. Expressions either return as True or False.
  3. Relational operators can be used in selection statements.

Keywords

relational operator
compare two values and produce the result of True or False
condition
an expression that evaluates to True or False
selection
used when there is more than one possible path for a program to follow

A common mistake

Mistake: The = operator is used for comparison.

In fact: When using Python for programming the == operator is used for comparison and the = operator is used for assignment. Other languages may not always use these operators for these tasks.

Check what you learned

From Oak National Academy's exit quiz. Choose every answer that is right.

What do relational operators do in a program?
What is the result of the expression `15 > 12`?
What will be displayed if score = 11 in the following code? ```if score < 5: print("You lose") elif score <= 10: print("Not bad!") else: print("You win!") ```

A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0. Read the licence

The wording comes from each publisher. The layout and the links to your syllabus are ours.