- # is comment
- a value can be assigned to several variables simultaneously
- variables must be defined (a value assigned)
- PEMDAS rule Applies
- integers are converted to float in mixed float and integer operations
- int(), float(), long() are conversion functions
Python Example 1
# calculates volume of a box # simultaneously value assignment length = height = width = 5 volume = length * height * width print volume # 125 # integer + float = float print volume + 0.0 # 125.0
Python Example 2
# PEMDAS Parenthesis Exponent Multiplication Division Addition Subtraction
print (2+2*2)/3
Python Example 3
a = 2 b = 3.0 print float(a) # 2.0 print int(b) # 3