Vorlesung 2
This commit is contained in:
21
Vorlesung 2/operatoren.py
Normal file
21
Vorlesung 2/operatoren.py
Normal 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")
|
||||
Reference in New Issue
Block a user