Abgabe aufgabe 5 teil 3 - 6, Aufgabe 6

main
Jonas Wächter 2022-11-09 12:30:01 +01:00
parent def1842083
commit 7ae105747c
2 changed files with 69 additions and 0 deletions

51
s1_a53_6.py 100644
View File

@ -0,0 +1,51 @@
def move_list_elemts():
list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
list2 = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
counter = 0
while counter < 7:
list1.append(list1.pop(0))
counter = counter + 1
print(list1)
def list_remove_duplicates():
word = "Donaudampfschiffahrtsgesellschaftsstewardess"
word_list = list(word)
print(len(word_list))
result_list = []
for letter in word:
if letter not in result_list:
result_list.append(letter)
print(result_list)
print(len(result_list))
def sort_list():
list1 = [[1, 2, 3], [2, 1, 3], [4, 0, 1]]
list1.sort(key=lambda x: x[1])
print(list1)
def fake_switch():
tier_name = 'Hund'
tier_sound = {'Hund': 'wuff', 'Katze': "miau"}
print(tier_sound[tier_name])
def main():
print("Aufgabe 3:")
move_list_elemts()
print("Aufgabe 4:")
list_remove_duplicates()
print("Aufgabe 5:")
sort_list()
print("Aufgabe 6:")
fake_switch()
if __name__ == '__main__':
main()

18
s1_a61_2.py 100644
View File

@ -0,0 +1,18 @@
def space_to_minus(text):
split_text = text.split(" ")
return "-".join(split_text)
def reverse_text_till_komma(text):
text_list = text.split(",")
text_list[0] = text_list[0][::-1]
return ",".join(text_list)
def main():
print(space_to_minus("This is a test"))
print(reverse_text_till_komma("Hallo,Welt"))
if __name__ == "__main__":
main()