PR3_Skriptsprachen_GruppeD_SL1/s1_a53_6.py

18 lines
533 B
Python
Raw Permalink Normal View History

2022-11-05 15:33:32 +01:00
if __name__ == "__main__":
2023-03-30 01:29:11 +02:00
# 5.3
nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print(nums[-3:] + nums[:-3])
# 5.4
def remove_duplicates(word: str):
2023-04-01 02:30:56 +02:00
return "".join(sorted(set(word), key=word.index))
2023-04-11 12:27:48 +02:00
print(remove_duplicates("Donaudampfschiffahrtsgesellschaftsstewardess"))
2023-03-30 01:29:11 +02:00
# 5.5
nums = [[1, 2, 3], [2, 1, 3], [4, 0, 1]]
nums.sort(key=lambda x: x[1])
# 5.6
def get_animal_sound(animal: str) -> str:
2023-04-01 02:30:56 +02:00
return {"Lion": "Growl", "Dog": "Bark", "Cat": "Meow"}.get(animal, "Not found.")