파이썬 math.pow() 메서드
예시
9의 값을 3의 거듭제곱으로 구합니다.
# Import math Library
import math
#Return the value of 9 raised
to the power of 3
print(math.pow(9, 3))
정의 및 사용
이 math.pow()
메서드는 y의 거듭제곱으로 거듭제곱된 x의 값을 반환합니다.
x가 음수이고 y가 정수가 아니면 ValueError를 반환합니다.
이 메서드는 두 인수를 모두 float로 변환합니다.
팁:math.pow(1.0,x)
또는 를 사용 math.pow(x,0.0)
하면 항상 1.0을 반환합니다.
통사론
math.pow(x, y)
매개변수 값
Parameter | Description |
---|---|
x | Required. A number which represents the base |
y | Required. A number which represents the exponent |
기술적 세부 사항
반환 값: | x 의 float 값을 y의 거듭제곱으로 나타내는 값(x y ) |
---|