Python Forum

Full Version: python 3 math formulas where to use ()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am having trouble using math formulas for 3d geometric shapes in python.

for example a tetrahedon:
The formula to find the edge is:
a = √2 (3v)^1/3

So in python 3:
A = math.sqrt (2) * (3*v)** (1/3)

How do I know the 1/3 should have been in () ?
I just keep guessing what to group together to get it to have the correct output.

I am trying to understand when and where to use (); when the math formula did not even have it.
I understand multiplication is not implied in python but not sure what other rules there are for converting math formulas to use in scripts.

If you google regular tetrahedron edge formula you will see the formula.
google formula

Thanks

Any help will be greatly appreciated.
Take a look here https://docs.python.org/3/reference/expr...precedence
Just like you have to memorize that multiplication happens before addition in math, these may be worth memorizing.