• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • Ruby
  • About
You are here: Home / Python / Python cube root – Find Cube Root of Number With math.pow() Function

Python cube root – Find Cube Root of Number With math.pow() Function

January 29, 2022 Leave a Comment

In Python, the easiest way we can find the cube root of a number is to use the pow() function from the Python math module.

import math

cube_root_of_10 = math.pow(10,1/3)

You can also use the built in ** operator to find the cube root of a number.

cube_root_of_10 = 10**(1/3)

The Python math module has many powerful functions which make performing certain calculations in Python very easy.

One such calculation which is very easy to perform in Python is finding the cube root of a number.

The pow() function from the Python math module also lets us compute cube roots.

The pow() function takes two numbers as input, the first number is the base and the second number is the exponent. The first number must be positive, but the second number can be negative.

For a cube root, we pass “1/3” to the second parameter in the pow() function.

Below are some examples of how to use the pow() function to find cube roots.

import math

print(math.pow(4, 1/3))
print(math.pow(9, 1/3))
print(math.pow(13, 1/3))
print(math.pow(90, 1/3))
print(math.pow(2182, 1/3))

#Output:
1.5874010519681994
2.080083823051904
2.3513346877207573
4.481404746557164
12.970346612351785

The Python pow() function can also be useful if you want to find the square root of a number or the nth root of a number in Python.

Finding the Cube Root of a Number with the ** Operator in Python

We can also use the built in ** to perform exponentiation in Python. To find a cube root with the ** operator, we just put “(1/3)” after **.

Unlike the pow() function, we can find the cube root of negative numbers with the ** operator.

Below are some examples of how to use the Python built in ** operator to find cube roots.

import math

print(4**(1/3))
print(9**(1/3))
print(-13**(1/3))
print(90**(1/3))
print(-2182**(1/3))

#Output:
1.5874010519681994
2.080083823051904
-2.3513346877207573
4.481404746557164
-12.970346612351785

Hopefully this article has been beneficial for you to learn how to find the cube root of a number in Python.

Other Articles You'll Also Like:

  • 1.  Check if Number is Between Two Numbers Using Python
  • 2.  Negate Boolean in Python with not Operator
  • 3.  Replace Forwardslashes in String Using Python
  • 4.  Check if Variable is Float in Python
  • 5.  Using Python to Replace Backslash in String
  • 6.  Convert Set to List in Python
  • 7.  How to Group By Columns and Find Variance in pandas
  • 8.  Sorting a List of Tuples by Second Element in Python
  • 9.  Truncate String in Python with String Slicing
  • 10.  Using Python to Append Character to String Variable

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About The Programming Expert

the programming expert main image

Welcome to The Programming Expert. We are a group of US-based programming professionals who have helped companies build, maintain, and improve everything from simple websites to large-scale projects.

We built The Programming Expert to help you solve your programming problems with useful coding methods and functions in various programming languages.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2023 · The Programming Expert · About · Privacy Policy