Teil 6 "Objekte ist neu

Repository aufgeräumt.
This commit is contained in:
2023-02-24 06:41:05 +01:00
parent c21159f36f
commit 3d8cb9128d
34 changed files with 196 additions and 0 deletions

23
teil5/dict/iter_kfz.py Normal file
View File

@@ -0,0 +1,23 @@
# encoding utf-8
kfz = {
'W':'Wuppertal',
'HH':'Hamburg',
'D':'Düsseldorf',
'DO':'Dortmund',
'H':'Hannover',
'M':'München'}
for key in kfz:
print(f' Kennzeichen {key} -> Stadt {kfz[key]}')
print()
for key, stadt in kfz.items():
print(f' Kennzeichen {key} -> Stadt {stadt}')
items = kfz.items()
keys = kfz.keys()
print(items)
print(keys)

12
teil5/dict/kfz.py Normal file
View File

@@ -0,0 +1,12 @@
# encoding utf-8
kfz = {
'W':'Wuppertal',
'HH':'Hamburg',
'D':'Düsseldorf',
'DO':'Dortmund',
'H':'Hannover',
'M':'München'}
print(kfz)
print(kfz['W'])

7
teil5/lists/append.py Normal file
View File

@@ -0,0 +1,7 @@
namen = ["Homer", "Marge", "Bart"]
namen.append('Lisa')
namen.append('Maggie')
print(namen)

9
teil5/lists/del.py Normal file
View File

@@ -0,0 +1,9 @@
zahlen1 = ['0','1','4','3','2','5']
zahlen2 = ['8','7','9','6']
zahlen1.extend(zahlen2)
print(f'komplett:{zahlen1}')
zahlen1.sort()
del zahlen1[3]
print(f'nach del:{zahlen1}')

6
teil5/lists/extend.py Normal file
View File

@@ -0,0 +1,6 @@
zahlen1 = ['0','1','2','3','4','5']
zahlen2 = ['6','7','8','9']
zahlen1.extend(zahlen2)
print(zahlen1)

View File

@@ -0,0 +1,4 @@
namen = ["Homer", "Marge", "Bart"]
for ind in range(0,len(namen)):
print(f'{ind}: {namen[ind]}')

5
teil5/lists/namen.py Normal file
View File

@@ -0,0 +1,5 @@
namen = ["Homer", "Marge", "Bart"]
print(namen[0])
print(namen[1])
print(namen[2])

8
teil5/lists/sort.py Normal file
View File

@@ -0,0 +1,8 @@
zahlen1 = ['0','1','4','3','2','5']
zahlen2 = ['8','7','9','6']
zahlen1.extend(zahlen2)
print(f'unsortiert:{zahlen1}')
zahlen1.sort()
print(f'sortiert:{zahlen1}')

3
teil5/tupel/tupel.py Normal file
View File

@@ -0,0 +1,3 @@
coords = (51.2562,7.1508)
print(coords)