ok, thanks.
What about.
"if n % 2 == 0"
You program in plain english is:
- Store the value 1 in the variable named "n".
- While the value of the variable named "n" is less than or equal to 20, do items 3-5. Otherwise jump to item 6.
- Divide the value of n by 2 and see whether the remainder equals 0. If it does, then do item 4. Otherwise skip 4 and go to item 5. The "%" is the modulus operator. It returns the remainder of the division of its left operand by its right operand (e.g. 5 % 2 == 1, 5 % 3 == 2, 5 % 4 == 1, 5 % 5 == 0). This line is the common check for an even number. If n is even, the remainder of its division by 2 is 0. Otherwise the remainder will be 1.
- Print the value of the variable n.
- Store the value of n plus 1 in n. I.e. increment the value of n. If n is 12 before this line, it will be 13 after it.
- Print "there, done.".
In Python, instead of using numbers, you use indentation to specify which lines belong to which "blocks":
n = 1while n <= 20: if n % 2 == 0: print n n = n + 1print "there, done."
The fact that the third, forth and fifth lines are indented shows that they belong to the while block, i.e. they are the commands to be executed while the expression in the while statement holds. Similarly, the double indentation of the "print n" line shows that it belongs the if statement above it (and that the "n = n + 1" line doesn't). Most other languages use braces to surround blocks instead.