Python math.pow() Metodo
Esempio
Trova il valore di 9 elevato alla potenza di 3:
# Import math Library
import math
#Return the value of 9 raised
to the power of 3
print(math.pow(9, 3))
Definizione e utilizzo
Il math.pow()
metodo restituisce il valore di x elevato a potenza y.
Se x è negativo e y non è un numero intero, restituisce un ValueError.
Questo metodo converte entrambi gli argomenti in un float.
Suggerimento: se utilizziamo math.pow(1.0,x)
o math.pow(x,0.0)
, restituisce sempre 1.0.
Sintassi
math.pow(x, y)
Valori dei parametri
Parameter | Description |
---|---|
x | Required. A number which represents the base |
y | Required. A number which represents the exponent |
Dettagli tecnici
Valore di ritorno: | Un float valore, che rappresenta il valore di x alla potenza di y (x y ) |
---|