Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.pow() Method

Python math.pow() Method

Python math Module Python math Module

Python math.pow(x, y) The method returns x raised to the power of y.

If x is negative and y is not an integer, a ValueError is returned. The method converts both arguments to floating-point numbers. math.pow(1.0,x) or math.pow(x,0.0) always returns 1.0.

Syntax

The syntax of the math.pow() method is as follows:

math.pow(x, y)

Parameter Description:

Return Value

Returns a floating-point number representing x raised to the power of y.

Example

The following example returns 9 to the power of 3:

Example

Import the math package

import

math

Output 9 to the power of 3

print

(

math

.

pow

(

9

,

3

)

)

Output result:


729.0

Python math Module Python math Module