The Line That Is Not True

Computing · Page 1 of 2

Name Date
DIRECTIONS: Read this line as math, then as Python. Fill in what x holds.
1Read it as math
→
2Read it as Python
→
3Write what it prints
as math x = x + 1
x − x = 1
0 = 1
As math it is false. It is also the commonest line in programming.
1x = 4
2x = x + 1
3print(x)
In math, = means the same.
In Python, = means work out the right side, and put the answer in the box on the left.
linex
1
2
3
what it prints 

Four Lines, One Box

Computing · Page 2 of 2

DIRECTIONS: Fill in what x holds after each line.
1x = 10
2x = x + 1
3x = x + 1
4x = x * 2
5print(x)
linex
1
2
3
4
5
what it prints 
  1. Lines 2 and 3 are exactly the same line. Why do they not do exactly the same thing?
  2. Swap lines 3 and 4 over, so the doubling happens first. What does the program print now? Work it out, do not guess.
  3. In math, does the order of the steps matter as much as it does here? Give an example either way.