Files
ProgrammierungUndDatenanalyse/Vorlesung 2/operatoren.py
dev weycloud 5562abd79b Vorlesung 2
2021-09-23 19:58:44 +02:00

21 lines
587 B
Python

# 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")