In the formula for calculating the volume of a sphere, the radius is raised to the power of 3. So, if I assign a variable such as sphere_radius to the radius, how would I raise that variable to the power of 3 (in shorthand form without having to multiply the radius three times) in my python statement to calculate the volume?
Asked
Active
Viewed 67 times
-2
-
[pow()](https://www.w3schools.com/python/ref_func_pow.asp) – Mohamad Ghaith Alzin Sep 02 '22 at 01:45
-
@MohamadGhaithAlzin please reference the official Python docs - [`pow()`](https://docs.python.org/3/library/functions.html#pow) - instead of a lousy, error-prone SEO-driven website. – MattDMo Sep 02 '22 at 01:46
1 Answers
0
In python, a**b
will raise a to the power of b.
For example:
cubed = radius ** 3

KingsDev
- 654
- 5
- 21
-
Thanks for the feedback. I will go ahead and check it out in my code. – superior_light Sep 03 '22 at 00:50
-
@superior_light If this helped you in any way upvote and mark as accepted as that helps a ton and can also help future readers – KingsDev Sep 03 '22 at 00:51