M&C6: The left hand side of assignment statement does not always need to be variable

For some students, it will be important to use assignment as an opportunity to discuss syntax and how a program is understood by the compiler. While many students may not respond positively if you equate the interpretation of a line of code to a sentence in English, it may resonate with some about how important it is to have rules. With this in mind, it is helpful to diagram lines of code much like one might diagram a sentence in English.

Python Example: Given assignment statements like “b + 1 = a” or “5 = a”, demonstrate how to properly identify how a statement will be read by the compiler.

RULE: <variable> = <value or expression>

x = 6          # LEGAL

x + 1 = 5      # ILLEGAL

4 = x          # ILLEGAL