Codemaxxers - 3.3 Mathematical Expressions PY Hacks
Apply your skills of math, logic, and coding.
Basic Algebraic Math hacks
Q1 (Exponents):
A cube has a side length of 4 units. What is its volume?
side = 4
volume = side ** 3
print(f"A cube with side length {side} has volume {volume}.")
A cube with side length 4 has volume 64.
Q2 (PEMDAS):
Evaluate the expression:
(12+8)/2+(3^2)
result = (12 + 8) / 2 + (3 ** 2)
print(f"The result of the expression is {result}.")
The result of the expression is 19.0.
Q3 (Algorithm):
Write Python code where you define variables and run commands that find the values of operations you apply onto them
a = 3
b = 4
c = (a ** 2 + b ** 2) ** 0.5
print(f"The value of c in pythagorean theorem is {c}.")
The value of c in pythagorean theorem is 5.0.
