math.pow() in Python Last Updated : 21 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report In Python, math.pow() is a function that helps you calculate the power of a number. It takes two numbers as input: the base and the exponent. It returns the base raised to the power of the exponent.In simple terms, if you want to find "x raised to the power y", you can use math.pow(x, y).Example: Python import math # Calculate 2 raised to the power of 3 r = math.pow(2, 3) print(r) Output8.0 Explanation:math.pow(2, 3) → Raises 2 to the power of 3.Returns 8.0 (float), even though the result is a whole number.Syntax of math.pow() method math.pow(x, y)Parametersx: The base number.y: The exponent.Return ValueReturns a floating-point number (float), even if the result is a whole number.Important Points About math.pow()It always returns a floating-point number (float), even if the result is a whole number.It only works with numbers (integers or floats).If you give it a negative base with a fractional exponent, it may give an error.Examples of math.pow() method 1. Power of a Fraction Python import math # Calculate (1/2) raised to the power of 2 r = math.pow(1/2, 2) print(r) Output0.25 Explanation: This code calculates (1/2)^2, which equals 0.25. The result is returned as a float (0.25).2. Negative Exponent Python import math # Calculate 2 raised to the power of -3 r = math.pow(2, -3) print(r) Output0.125 Explanation: This code calculates 2^(-3), which is the reciprocal of 2^3 (1/8 = 0.125). The result is returned as a float (0.125).3. Power with Floating-Point Numbers Python import math # Calculate 3.5 raised to the power of 2 r = math.pow(3.5, 2) print(r) Output12.25 Explanation: This code calculates 3.5^2, which equals 12.25. The result is returned as a float (12.25).4. Using math.pow() with Negative Numbers Python import math # Calculate (-2) raised to the power of 3 r = math.pow(-2, 3) print(r) Output-8.0 Explanation: This code calculates (-2)^3, which equals -8. The result is returned as a float (-8.0). Comment More infoAdvertise with us Next Article math.pow() in Python P pragatikheuvg Follow Improve Article Tags : Python Web Technologies Practice Tags : python Similar Reads numpy.power() in Python numpy.power(arr1, arr2, out = None, where = True, casting = 'same_kind', order = 'K', dtype = None) : Array element from first array is raised to the power of element from second element(all happens element-wise). Both arr1 and arr2 must have same shape and each element in arr1 must be raised to cor 3 min read pow() Function - Python pow() function in Python is a built-in tool that calculates one number raised to the power of another. It also has an optional third part that gives the remainder when dividing the result. Example:Pythonprint(pow(3,2))Output9 Explanation: pow(3, 2) calculates 32 = 9, where the base is positive and t 2 min read Python | sympy.Pow() method With the help of sympy.Pow() method, we can find a raised to the power of b where a and b are parameters to the method. Syntax: Pow(a, b) Parameter: a - It denotes an integer. b - It denotes an integer. Returns: Returns an integer which is equal to a raised to the power of b, i. e., a^b. Example #1: 1 min read Python | cmath.exp() method With the help of cmath.exp() method, we can find the exponent of any number by passing it to cmath.exp() method. Syntax : cmath.exp(value) Return : Return the exponential value. Example #1 : In this example we can see that by using cmath.exp() method, we are able to get the values of exponent by pas 1 min read numpy.float_power() in Python numpy.float_power(arr1, arr2, out = None, where = True, casting = 'same_kind', order = 'K', dtype = None) : Array element from first array is raised to the power of element from second element(all happens element-wise). Both arr1 and arr2 must have same shape. float_power differs from the power func 3 min read Like