I'm looking to do the following in python:
[0.12 x 1.616 x (100 x 0.019 x 40)^1/3] x 300 x 527.5
I can't work out how to raise to the power of a fraction. I want the output to be decimal.
(100 x 0.019 x 40)^1/3
I'm looking to do the following in python:
[0.12 x 1.616 x (100 x 0.019 x 40)^1/3] x 300 x 527.5
I can't work out how to raise to the power of a fraction. I want the output to be decimal.
(100 x 0.019 x 40)^1/3
You can use the math.pow
function:
>>> import math
>>> math.pow(27, 1/3)
3.0
>>> help(math.pow)
Help on built-in function pow in module math:
pow(x, y, /)
Return x**y (x to the power of y).
Or simply the **
(exponent) operator:
>>> 27 ** (1/3)
3.0
Also be careful of your order of operations:
>>> 27 ** 1/3 # same as: (27 ** 1) / 3
9.0
>>> 27 ** (1/3)
3.0