CKTIS / Python
math.pi
Liefert als float eine Näherung des Verhältnisses von Umfang zu Durchmesser.
Version: Python 3.14; repository image, production runtime not attested
Syntax
math.piLiefert als float eine Näherung des Verhältnisses von Umfang zu Durchmesser.
Radius 3 ergibt Durchmesser 6 und Umfang 6π, gerundet 18,85. Eine halbe Drehung misst π Radiant oder 180 Grad.
Gerundet wird erst für die Ausgabe.
import math
assert round(2 * math.pi * 3, 3) == 18.85
assert math.degrees(math.pi) == 180.0
Beispiele
import math
print(round(2 * math.pi * 3, 3))
print(round(math.degrees(math.pi), 1))
Ergebnis
18.85 180.0
Gerundet wird erst für die Ausgabe.