OCR Computing A-Level Revision

Assignment Statements (2.4.a)

An assignment statement simply assigns a value to a variable. The syntax varies, as an assignment statement (let x equal 1) needs to be different to a comparison (if x equals 1). For example, in python, the syntax for an assignment statement is x = 1, whereas the syntax for a comparison is x == 1 (double equals). This syntax is common for several languages derived from C, including C++, Java, and PHP.

In exam questions, you may be asked to highlight assignment statements or comparisons based on the type of operation.