Home Communities
IT Knowledge
Inspiration
Languages
EN

# Python - math.pow() method example

0 points
Created by:
357

`math.pow()` is a method that returns base raised to the power of exponent (`value^exponent` operation).

``````import math

#               base    exponent
print(math.pow( 1,      2   ) )     # 1.0
print(math.pow( 2,      2   ) )     # 4.0
print(math.pow( 3,      2   ) )     # 9.0

print(math.pow( 0,      3   ) )     # 0.0
print(math.pow( 0.5,    0.3 ) )     # 0.8122523963562356
print(math.pow( -1,     4   ) )     # 1.0

print(math.pow( -0.5,   -2  ) )     # 4.0
print(math.pow( -2.0,   -2  ) )     # 0.25
print(math.pow( 2.0,    0.5 ) )     # 1.4142135623730951

print(math.pow( 0,     -0.4 ) )     # ValueError``````

## 1. Documentation

 Syntax ``math.pow(base, exponent)`` Parameters The method takes two arguments. `base` - base of power`exponent` - exponent used with a base Result `number` value calculated as base raised to the power of exponent or `ValueError` if the operation can not be executed. Description `pow` is a static method that returns base raised to the power of exponent (`value^exponent` operation).
Join to our subscribers to be up to date with content, news and offers.