capypad
0 Tage Serie
python / beginner
Snippet

Zugriff auf mathematische Konstanten

Das 'math'-Modul bietet Zugriff auf wichtige mathematische Konstanten wie Pi, was genauer ist als die manuelle Eingabe.

snippet.py
python
1
2
3
4
5
import math
 
radius = 5
area = math.pi * radius * radius
print(area)
Erklärung
1
import math
Lädt die eingebaute Mathe-Bibliothek in das Skript.
2
math.pi
Greift auf den konstanten Wert von Pi zu (ca. 3,14159).