Add LF5 Aufgaben
This commit is contained in:
parent
ba8b79dd36
commit
6685e379a0
18
S1/LF5/2021-11-15_Aufgabe-3.py
Normal file
18
S1/LF5/2021-11-15_Aufgabe-3.py
Normal file
@ -0,0 +1,18 @@
|
||||
text = """Drei Chinesen mit dem Kontrabaß
|
||||
saßen auf der Straße und erzählten sich was.
|
||||
Da kam ein Polizist: "Ja was ist denn das?"
|
||||
Drei Chinesen mit dem Kontrabaß."""
|
||||
|
||||
sauberer_text = ""
|
||||
for zeichen in text:
|
||||
if zeichen in " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüßÄÖÜ":
|
||||
sauberer_text += zeichen
|
||||
elif zeichen == "\n":
|
||||
sauberer_text += " "
|
||||
|
||||
wörter = sauberer_text.split(" ")
|
||||
deduplizierte_wörter = list(set(wörter))
|
||||
|
||||
print(deduplizierte_wörter)
|
||||
|
||||
|
17
S1/LF5/2021-11-15_Sensordaten.py
Normal file
17
S1/LF5/2021-11-15_Sensordaten.py
Normal file
@ -0,0 +1,17 @@
|
||||
def maxPeriod(valueList, mindestwert):
|
||||
"""
|
||||
Gibt die Länge der am meinsten hintereinander liegenden Listenelemente aus valueList zurück,
|
||||
die größer oder gleich mindestwert sind.
|
||||
"""
|
||||
maxlen = 0
|
||||
current_len = 0
|
||||
for i in valueList:
|
||||
if i >= mindestwert:
|
||||
current_len += 1
|
||||
else:
|
||||
if current_len > maxlen:
|
||||
maxlen = current_len
|
||||
current_len = 0
|
||||
return maxlen
|
||||
|
||||
print(maxPeriod([20, 22, 23, 21, 19, 18, 20, 22, 23, 23, 24, 22, 21], 22))
|
25
S1/LF5/2021-12-20_Hauptstädte.py
Normal file
25
S1/LF5/2021-12-20_Hauptstädte.py
Normal file
@ -0,0 +1,25 @@
|
||||
hauptstädte = {}
|
||||
|
||||
print("** Datenerfassung **")
|
||||
|
||||
while True:
|
||||
print("Bitte Land eingeben")
|
||||
land = input()
|
||||
if land == "":
|
||||
break
|
||||
print("Bitte Stadt eingaben")
|
||||
stadt = input()
|
||||
hauptstädte[land] = stadt
|
||||
|
||||
print("** Datenabfrage **")
|
||||
|
||||
while True:
|
||||
print("Bitte Land eingeben")
|
||||
land = input()
|
||||
if land == "":
|
||||
break
|
||||
if land in hauptstädte:
|
||||
print(hauptstädte[land])
|
||||
else:
|
||||
print("Land existiert nicht")
|
||||
|
55
S1/LF5/2021-12-20_Wörterbuch.py
Normal file
55
S1/LF5/2021-12-20_Wörterbuch.py
Normal file
@ -0,0 +1,55 @@
|
||||
commands = {}
|
||||
|
||||
def add_command(name):
|
||||
def decorator(f):
|
||||
commands[name] = f
|
||||
return f
|
||||
return decorator
|
||||
|
||||
@add_command("erstellen")
|
||||
def erstelleWörterbuch():
|
||||
wb = {}
|
||||
for i in range(10):
|
||||
native = input()
|
||||
translated = input()
|
||||
wb[native] = translated
|
||||
return wb
|
||||
|
||||
@add_command("suchen")
|
||||
def findeÜbersetzung(wb, wort):
|
||||
return wb.get(wort)
|
||||
|
||||
@add_command("auflisten")
|
||||
def erstelleIndex(wb):
|
||||
return list(wb.keys())
|
||||
|
||||
@add_command("existiert")
|
||||
def existiertÜbersetzung(wb, übersetzung):
|
||||
return übersetzung in list(wb.values())
|
||||
|
||||
if __name__ == "__main__":
|
||||
import inspect
|
||||
|
||||
wörterbuch = {}
|
||||
while True:
|
||||
print("Mögliche Aktionen:")
|
||||
print(", ".join(list(commands.keys())))
|
||||
print("Geben sie eine Aktion an")
|
||||
aktion = input()
|
||||
if aktion not in commands.keys():
|
||||
print("Aktion nicht verfügbar")
|
||||
continue
|
||||
ag = []
|
||||
for arg in list(inspect.getargspec(commands[aktion]).args):
|
||||
if arg == "wb":
|
||||
ag.append(wörterbuch)
|
||||
else:
|
||||
print("argument", arg)
|
||||
ag.append(input())
|
||||
|
||||
r = commands[aktion](*ag)
|
||||
|
||||
if aktion == "erstellen":
|
||||
wörterbuch = r
|
||||
else:
|
||||
print(r)
|
14
S1/LF5/2022-02-07_Musterklausur/Aufgabe1.py
Executable file
14
S1/LF5/2022-02-07_Musterklausur/Aufgabe1.py
Executable file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
l = []
|
||||
|
||||
while True:
|
||||
try:
|
||||
i = int(input("Eine Zahl: "))
|
||||
except:
|
||||
break
|
||||
|
||||
l.append(i)
|
||||
|
||||
s = sorted(l)
|
||||
print(s)
|
25
S1/LF5/2022-02-07_Musterklausur/Aufgabe2.py
Executable file
25
S1/LF5/2022-02-07_Musterklausur/Aufgabe2.py
Executable file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
hs = {}
|
||||
|
||||
print("Bitte Länder eingeben:")
|
||||
|
||||
while True:
|
||||
land = input("Land: ")
|
||||
if land == "":
|
||||
break
|
||||
|
||||
stadt = input("Hauptstadt: ")
|
||||
if stadt == "":
|
||||
break
|
||||
|
||||
hs[land] = stadt
|
||||
|
||||
print("Nun Länder abfragen:")
|
||||
|
||||
while True:
|
||||
land = input("Land: ")
|
||||
if land == "":
|
||||
break
|
||||
|
||||
print(hs[land])
|
7
S1/LF5/2022-02-07_Musterklausur/Aufgabe3.py
Executable file
7
S1/LF5/2022-02-07_Musterklausur/Aufgabe3.py
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
schulden = int(input("Schulden (€): "))
|
||||
zinsen = int(input("Zinsen (%): "))
|
||||
rate = int(input("Monatliche Rate (€): "))
|
||||
|
||||
print("Du bist nach {} Monaten schuldenfrei".format((schulden*((zinsen/100)+1))/rate))
|
23
S1/LF5/2022-02-07_Musterklausur/Aufgabe4.py
Executable file
23
S1/LF5/2022-02-07_Musterklausur/Aufgabe4.py
Executable file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
def generatePasswort(name):
|
||||
vokale = "aeiouäöüAEIOUÄÖÜ "
|
||||
|
||||
pw = ""
|
||||
|
||||
for n in name:
|
||||
if n not in vokale:
|
||||
pw += n
|
||||
|
||||
return pw
|
||||
|
||||
tests = [
|
||||
"Isabell Bauer",
|
||||
"Markus Müller",
|
||||
"Annie Claasen",
|
||||
]
|
||||
|
||||
for t in tests:
|
||||
print(t, ":", generatePasswort(t))
|
||||
|
||||
print(generatePasswort(input("Name: ")))
|
Loading…
Reference in New Issue
Block a user