3.3 Continued - Mathematical Operations

  • Addition: a + b
  • Subtraction: a - b
  • Multiplication: a * b
  • Division: a / b
  • Modulus (remainder of a/b): a MOD b
  • For python it is %
  • Math in order of operations
  • MOD is held to the value of multiplication + division in PEMDAS
num1 = 40
num2 = num1 / 2 
num3 = 6 * num2 + 3 # pemdas --> multiplication then additon
result = num2 % 6 * num1 + 4 - num3 / 2 # pemdas --> modulus, then multiplication, then subtraction, then division
print (result)
22.5

Example #2

What will the code below print?

numb1 = 40
numb2 = numb1 /4 
numb3 = numb2 * 10 + 3
print(numb3)