PR3_Steinberger/SL1/s1_a53_6.py

60 lines
1.1 KiB
Python

#Aufgabe 5.3
liste1 = [1,2,3,4,5,6,7,8,9,10]
l = liste1[len(liste1)-3 : len(liste1)]
for i in range(1,4):
x = liste1.pop()
liste1.insert(0, x)
print(liste1)
#Aufgabe 5.4
from xmlrpc.client import boolean
from pickle import TRUE
list1 = []
string1 = "Donaudampfschifffahrtsgesellschaft".lower()
list1.extend(string1)
count = 0
print("Laenge der Liste vorher: ", len(list1))
i = 0
while i < len(list1):
element = list1[i]
count = list1.count(element)
if count > 1:
i = 0
for j in range(1,count+1):
list1.remove(element)
else:
i = i+1
print("Laenge der Liste nachher: ", len(list1))
#Aufgabe 5.5
list1 = [[1,2,3],[2,1,3],[4,0,1]]
i = 0
while i < len(list1)-1:
save_string = list1[i]
if list1[i+1][1] < list1[i][1]:
list1[i] = list1[i+1]
list1[i+1] = save_string
i = 0
else:
i = i+1
print(list1)
#Aufgabe 5.6
geraeusch = {
"Hund" : "Wuff",
"Katze":"Miau",
"Esel" : "Ia"
}
def tier_geraeusch(tiername):
print(geraeusch[tiername])
tier_geraeusch("Hund")