Demoprogramme
This commit is contained in:
23
teil24/print_type.py
Normal file
23
teil24/print_type.py
Normal file
@@ -0,0 +1,23 @@
|
||||
#encoding:utf-8
|
||||
def print_type(value):
|
||||
match value:
|
||||
case int():
|
||||
print('Integer')
|
||||
case str():
|
||||
print('String')
|
||||
case list():
|
||||
print('Liste')
|
||||
case dict() as d:
|
||||
print(f'Dictionary mit {len(d)} Einträgen')
|
||||
case _:
|
||||
print('unbekannter Datentyp')
|
||||
|
||||
print_type(1) #Integer
|
||||
|
||||
print_type('The Simpsons') # String
|
||||
|
||||
print_type([1, 2, 3]) # Liste
|
||||
|
||||
print_type({'a': 1, 'b': 2, 'c': 3}) # Dictionary
|
||||
|
||||
print_type(1.0) #float ist nicht implentiert
|
Reference in New Issue
Block a user