Teil 9: Typkonvertierung.

This commit is contained in:
2023-03-05 09:50:37 +01:00
parent 5512ec868c
commit c025b7fe47
12 changed files with 75 additions and 0 deletions

View File

@@ -12,4 +12,6 @@ CC-BY-SA Olli Graf
| 5 | Listen Dictionaries und Tupel|
| 6 | Objekte|
| 7 | Module|
| 8 | Exceptions|
| 9 | Typkonvertierung|

1
teil7/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
partner/__pycache__

View File

@@ -0,0 +1,9 @@
class Anschrift:
def __init__(self, strasse, hausnummer, plz, ort):
self.strasse = strasse
self.hausnummer = hausnummer
self.plz = plz
self.ort = ort
def __str__(self):
return f'{self.strasse} {self.hausnummer} \n {self.plz} {self.ort}'

1
teil9/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
__pycache__

25
teil9/bool.py Normal file
View File

@@ -0,0 +1,25 @@
from namen import namen
### String nach Boolean
print('String nach Boolean')
print(bool('True')) # ist True
print(bool('Test')) # ist True
print(bool('False')) # ist True
print(bool('')) # ist False
### int nach Boolean
print('int nach Boolean')
print(bool(0)) # ist False
print(bool(1)) # ist True
print(bool(2)) # ist True
### List nach Boolean
print('List nach Boolean')
print(bool(namen)) # ist True
print(bool([])) # ist False

4
teil9/bytearray.py Normal file
View File

@@ -0,0 +1,4 @@
some_chars = [65,66,67,68]
print(bytearray('Homer',encoding='utf-8'))
print(bytearray(some_chars))

4
teil9/bytes.py Normal file
View File

@@ -0,0 +1,4 @@
some_chars = [65,66,67,68]
print(bytes('Homer', encoding='utf-8'))
print(bytes(some_chars))

9
teil9/int.py Normal file
View File

@@ -0,0 +1,9 @@
eingabe = input('Dein Alter (Jahre): ')
alter = int(eingabe)
print(f'Du bist {alter} Jahre alt.')

1
teil9/namen.py Normal file
View File

@@ -0,0 +1 @@
namen = ["Homer", "Marge", "Bart"]

5
teil9/set.py Normal file
View File

@@ -0,0 +1,5 @@
from namen import namen
print(set(namen))
print(set("Jimbo"))

10
teil9/str.py Normal file
View File

@@ -0,0 +1,10 @@
wert = 3
#str = 'Die ' + wert + ' Musketiere'
str = 'Die ' + str(wert) + ' Musketiere'
print(str)

4
teil9/tupel.py Normal file
View File

@@ -0,0 +1,4 @@
from namen import namen
print(tuple(namen))
print(tuple('Jimbo'))