import math
4 * math.pi * 6371**2
510064471.90978825
Die installierte Python-Version ist direkt nach dem Starten des interaktiven Python-Interpreters zu sehen. Die aktuellste Version kann von der offiziellen Website heruntergeladen werden.
import antigravity
öffnet den Webbrowser mit dem xkcd-Comic über Python.
import this
gibt das Zen von Python am Bildschirm aus:
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren’t special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one – and preferably only one – obvious way to do it.
Although that way may not be obvious at first unless you’re Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it’s a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea – let’s do more of those!
Der Befehl import math
bewirkt, dass man danach die im Modul math
enthaltenen Befehle verwenden kann.
import math
4 * math.pi * 6371**2
510064471.90978825
Die Erdoberfläche beträgt also ungefähr 510 Millionen km².
11 + 27 + 15 + 10 + 33 + 18 + 25 + 22 + 39 + 11) / 10 (
21.1
11 * 27 * 15 * 10 * 33 * 18 * 25 * 22 * 39 * 11)**(1/10) (
19.034672698028626
import math
5**5 - math.pi) * 19/3) / (math.sqrt(13) + 7**(2/3)) ((
2721.563542502226
Den Befehl math.Sqrt(4)
gibt es nicht – da Python zwischen Groß- und Kleinschreibung unterscheidet, ist math.Sqrt
nicht identisch mit math.sqrt
. Letzteres ist die korrekte Schreibweise der Wurzelfunktion, welche im math
-Modul enthalten ist.
Richtig wäre also:
4) math.sqrt(
2.0