EN
Python - math.pow() method example
0 points
math.pow()
is a method that returns base raised to the power of exponent (value^exponent
operation).
xxxxxxxxxx
1
import math
2
3
# base exponent
4
print(math.pow( 1, 2 ) ) # 1.0
5
print(math.pow( 2, 2 ) ) # 4.0
6
print(math.pow( 3, 2 ) ) # 9.0
7
8
print(math.pow( 0, 3 ) ) # 0.0
9
print(math.pow( 0.5, 0.3 ) ) # 0.8122523963562356
10
print(math.pow( -1, 4 ) ) # 1.0
11
12
print(math.pow( -0.5, -2 ) ) # 4.0
13
print(math.pow( -2.0, -2 ) ) # 0.25
14
print(math.pow( 2.0, 0.5 ) ) # 1.4142135623730951
15
16
print(math.pow( 0, -0.4 ) ) # ValueError
Syntax |
xxxxxxxxxx 1 math.pow(base, exponent) |
Parameters |
The method takes two arguments.
|
Result |
|
Description | pow is a static method that returns base raised to the power of exponent (value^exponent operation). |