Mathematical Operations in Python - Hacks
Categories: PythonApply 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?
length = 4
volume = (length * length * length)
print(volume)
64
Q2 (PEMDAS):
Evaluate the expression:
(12+8)/2+(3^2)
length1 = 2
length2 = 3
result = (6*length1 + 4*length1)/length1 + (length2**length1)
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
Cookie = 3
Apple = 9
#Apply Operations
result = (Cookie*2 + Apple*4)/Apple - (Cookie**9)
#Print Result
print(result)
-19678.333333333332
