Basic Algebraic Math hacks

Q1 (Exponents):

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


side = 4
volume = side ** 3  # s^3
print(f"Side = {side} units")
print(f"Volume = side^3 = {side}^3 = {volume} cubic units")

# Alternative using math.pow (returns float)
import math
print("Result:", int(math.pow(side, 3)))

Side = 4 units
Volume = side^3 = 4^3 = 64 cubic units
Result: 64

Q2 (PEMDAS):

Evaluate the expression:

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

result = (12 + 8) / 2 + (3 ** 2)
print(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

# Define variables
a = 12
b = 8
c = 3

# Apply operations
sum_ab = a + b              # Addition
average = (a + b) / 2       # Average of a and b
square_c = c ** 2           # Exponentiation

# Combine operations
result = average + square_c

# Print results
print("a + b =", sum_ab)
print("(a + b) / 2 =", average)
print("c squared =", square_c)
print("Final result =", result)

a + b = 20
(a + b) / 2 = 10.0
c squared = 9
Final result = 19.0

Diagram showing mathematical operations