A few words about Python Syntax

  1. # is comment
  2. a value can be assigned to several variables simultaneously
  3. variables must be defined (a value assigned)
  4. PEMDAS rule Applies
  5. integers are converted to float in mixed float and integer operations
  6. 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