Browse Source

Teil 9: Typkonvertierung.

develop teil9
Raspithek 2 years ago
parent
commit
c025b7fe47
  1. 2
      Readme.md
  2. 1
      teil7/.gitignore
  3. 9
      teil7/partner/Anschrift.py
  4. 1
      teil9/.gitignore
  5. 25
      teil9/bool.py
  6. 4
      teil9/bytearray.py
  7. 4
      teil9/bytes.py
  8. 9
      teil9/int.py
  9. 1
      teil9/namen.py
  10. 5
      teil9/set.py
  11. 10
      teil9/str.py
  12. 4
      teil9/tupel.py

2
Readme.md

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

1
teil7/.gitignore

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

9
teil7/partner/Anschrift.py

@ -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

@ -0,0 +1 @@
__pycache__

25
teil9/bool.py

@ -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

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

4
teil9/bytes.py

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

9
teil9/int.py

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

1
teil9/namen.py

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

5
teil9/set.py

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

10
teil9/str.py

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

4
teil9/tupel.py

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