Python math.pow()-Methode
Python math.pow(x, y)Die Methode gibt x hoch y zurück.
Wenn x negativ und y keine ganze Zahl ist, wird ein ValueError zurückgegeben. Die Methode konvertiert beide Argumente in Gleitkommazahlen. math.pow(1.0, x) oder math.pow(x, 0.0) gibt immer 1.0 zurück.Syntax
Die Syntax der Methode math.pow() lautet:
math.pow(x, y)
Parameter description:
- x-- Erforderlich, eine Zahl, die die Basis darstellt.
- y-- Erforderlich, eine Zahl, die den Exponenten darstellt.
Rückgabewert
Gibt eine Gleitkommazahl zurück, die x hoch y darstellt.
Beispiel
Das folgende Beispiel gibt 9 hoch 3 zurück:
Beispiel
# Importiere das math-Paket
import math
# Ausgabe: 9 hoch 3
print(math.pow(9, 3))
import math
# Ausgabe: 9 hoch 3
print(math.pow(9, 3))
Ausgabeergebnis:
729.0Andere Erweiterungen
Python math-Modul