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

29
Vorlesung 2/variablen.py Normal file
View File

@@ -0,0 +1,29 @@
# Variablen und Datentypen
a = True # Datentyp bool
b = False
print("a =", a, "Type: " , type(a))
char1 = 'A' # Datentyp char
char2 = '!'
char3 = '#'
print("char1 =", char1, "Type: " , type(char1))
satz = "Hallo Welt!" # Datentyp string
print("satz =", satz, "Type: " , type(satz))
zahl1 = 4 # Datentyp Integer speichert ganze Zahlen
print("zahl1 =", zahl1, "Type: " , type(zahl1))
zahl2 = 3.5 # Datentyp float
print("zahl2 =", zahl2, "Type: " , type(zahl2))
print("zahl1 =", zahl1, "Speicher-Adresse: ", id(zahl1))
print("zahl2 =", zahl2, "Speicher-Adresse: ", id(zahl2))
# zahl3 verweist jetzt auf die gleiche speicheradresse wie zahl1
zahl3 = zahl1
print("zahl3 =", zahl3, "Speicher-Adresse: ", id(zahl3))
# Typenkonvertierung:
zahl3 = str(zahl1)
print("zahl3 =", zahl3, "Type: " , type(zahl3))