Fall 2024 - P3
3.1 Mathematical Expressions; Mathematical Operations
Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations
Mathematical Operations
Understanding Mathematical Operations in Code
Mathematical operations are fundamental to programming, enabling us to perform calculations, manipulate data, and solve complex problems. Here’s a quick overview of how these operations work in code.
Basic Operations
- Addition (+): Combines values.
result = 5 + 3 # result is 8
- Subtraction (-): Calculates the difference.
result = 10 - 4 # result is 6
- Multiplication (*): Scales a value.
result = 7 * 6 # result is 42
- Exponentiation (^): Raising a number to a power can be done using the
**
operator.result = 2 ** 3 # result is 8
- Modulus (%): Finds the remainder of division.
result = 10 % 3 # result is 1