Fall 2024 - P2
Big Idea 3 | .1 | .2 | .3 | .4 | .5 | .6 | .7 | .8 | .10 |
3.3.2 Mathematical Expressions (P2)
Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations
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)