34 lines
811 B
Python
34 lines
811 B
Python
|
print("Teilaufgabe 5.3")
|
||
|
# Durch das Prinzip von Slicing und Verketten
|
||
|
list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||
|
newlist = list[7:] + list[:7]
|
||
|
|
||
|
print(newlist)
|
||
|
|
||
|
print("\nTeilaufgabe 5.4")
|
||
|
long_word = "Donaudampfschiffahrtsgesellschaftsstewardess"
|
||
|
|
||
|
char_array = [*long_word]
|
||
|
print(char_array)
|
||
|
print("Das Wort hat", len(char_array), "viele Buchstaben.")
|
||
|
|
||
|
unique_characters = set(char_array)
|
||
|
print(unique_characters)
|
||
|
print("Das Wort hat", len(unique_characters), "eindeutige Buchstaben.")
|
||
|
|
||
|
print("\nTeilaufgabe 5.5")
|
||
|
list = [[1, 2, 3], [2, 1, 3], [4, 0, 1]]
|
||
|
list.sort(key=lambda x: x[1])
|
||
|
print(list)
|
||
|
|
||
|
print("\nTeilaufgabe 5.6")
|
||
|
|
||
|
|
||
|
def tiergeraeusch(tier):
|
||
|
return {"kuh": "muuh", "schwein": "oink", "pferd": "wieher"}[tier]
|
||
|
|
||
|
|
||
|
print(tiergeraeusch("kuh"))
|
||
|
print(tiergeraeusch("schwein"))
|
||
|
print(tiergeraeusch("pferd"))
|