Use conditionals to detect whether a condition is true and only run code in certain cases
Use assignment operators to change the value of a variable
Use comparison operators to compare values
Use logical operators to check multiple conditions at the same time or reverse the value of a boolean
Distinguish between assignment, comparison, and logical operators
Boolean: A boolean is a data type that has only two possible values: true or false. These two values can correspond to a lot of meanings, such as on or off. Comparison or equality testing statements (such as x > 4) evaluate to a boolean because x is either greater than 4 (true) or not greater than 4 (false). Booleans can be represented as words or numbers. So if you want to create a boolean variable named “playerAlive” to track whether the player is alive, you could do this:
var playerAlive = true;
var playerAlive = 1;
The computer will interpret both lines of code the same.
Conditional Statement: A conditional statement checks if a condition is true and then only executes code if the condition is true. Examples of conditional statements are “if” statements or “if-else” statements.
Assignment Operator: Assignment operators assign a value on the right side of the operator to the left side of the operator. When you’re using an assignment operator, it will only modify the value on the left side of the operator. These are shortcuts for assignments that could be written out in a slightly longer way. For example, you can use the assignment operator *= to assign the value of x * y to x (x *= y). However, you could also write this out as x = x * y.
Comparison Operator: Comparison operators check the values or expressions on the left and right side of the operator and return a boolean value of true or false based on the comparison. For example, you can check if x is equal to y (x == y), if x is not equal to y (x != y), or whether x is less than y (x < y).
Logical Operator: Logical operators take one or two boolean values and return a boolean value. For example, they can check if both are true (&&) or if either is true (||). The logical not operator (!) returns the opposite of a boolean value.
Nested Conditionals: You can add conditionals within conditionals. This is helpful if you want to check two conditions.
Students learn about and experiment with conditional statements, which they can use to programmatically make decisions based on one or more conditions or variables in the program. The operators they learn allow them to perform calculations and check conditions.
What is the difference between the following pieces of code?
x = y
x == y
x === y
UK equivalent grade/class - Year 7 +
Key Stage 3
design, use and evaluate computational abstractions that model the state and behaviour of real-world problems and physical systems
understand several key algorithms that reflect computational thinking (for example, ones for sorting and searching); use logical reasoning to compare the utility of alternative algorithms for the same problem
use two or more programming languages, at least one of which is textual, to solve a variety of computational problems; make appropriate use of data structures(for example, lists, tables or arrays); design and develop modular programs that use procedures or functions
understand simple Boolean logic(for example, AND, OR and NOT) and some of its uses in circuits and programming; understand how numbers can be represented in binary, and be able to carry out simple operations on binary numbers(for example, binary addition, and conversion between binary and decimal)
understand how instructions are stored and executed within a computer system; understand how data of various types (including text, sounds and pictures) can be represented and manipulated digitally, in the form of binary digits
Key Stage 4
develop their capability, creativity and knowledge in computer science, digital media and information technology