Método Python math.pow()
Exemplo
Encontre o valor de 9 elevado à potência de 3:
# Import math Library
import math
#Return the value of 9 raised
to the power of 3
print(math.pow(9, 3))
Definição e uso
O math.pow()
método retorna o valor de x elevado à potência y.
Se x for negativo e y não for um inteiro, ele retornará um ValueError.
Este método converte ambos os argumentos em um float.
Dica: Se usarmos math.pow(1.0,x)
ou math.pow(x,0.0)
, ele sempre retornará 1.0.
Sintaxe
math.pow(x, y)
Valores de parâmetro
Parameter | Description |
---|---|
x | Required. A number which represents the base |
y | Required. A number which represents the exponent |
Detalhes técnicos
Valor de retorno: | Um float valor, representando o valor de x elevado à potência de y (x y ) |
---|