Vorlesung 2

This commit is contained in:
dev weycloud
2021-09-23 19:58:44 +02:00
parent b842733193
commit 5562abd79b
10 changed files with 170 additions and 1 deletions

21
Vorlesung 2/operatoren.py Normal file
View File

@@ -0,0 +1,21 @@
# Operatoren
# Positive Zahl
x = 12/7
print("x: ", x)
# Rundung und Konvertierung
rx = round(x,3)
print("x gerundet auf drei Stellen: ", rx)
rx = round(x)
print("x gerundet auf null Stellen: ", rx)
ix = int(x)
print("int(x): ", ix)
# hier einige Beispiele zum Testen:
print("3/2 =", 3/2)
print("5%3 =", 5%3, "# Rest einer Ganzzahldivision")
print("5//3 =", 5//3, "# Ganzzahldivision")
print("2**3 =", 2**3, "# Potenzieren")
print("4**(1/2) =", 4**(1/2), "# naive Berechnung der Wurzel, 4^(1/2)")
print("(3*2 -4 )**2 =", (3*2 -4 )**2, "# Punkt vor Strich, Klammern und Potenz")