Page
2.10 Programming Page 10
Important Facts About Variables:
1. Variable names are case sensitive. X is not the same as x.
2. There are shortcuts for operations with variables.
+= will add one to the variable
e.g
x = 0
x += 1
x -= 1 will subtract one from the variable
You can add any amount by adding an integer +=3
e.g. x+=3 adds 3 to x every time the command executes.
3. There is a process called "TypeCasting". If there are two different variable types used in an equation Python will force them all to be floating point.
e.g. If x is an integer and y is a float z= x * y will result in z being a float answer.
4. Large numbers are written in Exponential Form.
e.g. 20.12 raised to the power of 8 is written as 20.12E8
Practice Activity:
a = 10
a += 2
print(a)