Basic Algebraic Math hacks

Q1 (Exponents):

A cube has a side length of 4 units. What is its volume?

# Q1 (Exponents)
side = 4
volume = side ** 3
print("Volume:", volume)

Volume: 125

Q2 (PEMDAS):

Evaluate the expression:

(12+8)/2+(3^2)

# Q2 (PEMDAS)
# Interpret 3^2 as exponent (3**2 in Python)
result = (12 + 8) / 2 + (3 ** 2)
print("Result:", result)

Result: 19.0

Q3 (Algorithm):

Write Python code where you define variables and run commands that find the values of operations you apply onto them

# Q3 (Algorithm) — define variables and show operations
a = 7
b = 4
sum_ab = a + b
prod_ab = a * b
avg_ab = (a + b) / 2
power = a ** b
print("a =", a, "b =", b)
print("Sum:", sum_ab)
print("Product:", prod_ab)
print("Average:", avg_ab)
print("a ** b:", power)

a = 7 b = 4
Sum: 11
Product: 28
Average: 5.5
a ** b: 2401

Diagram showing mathematical operations