initial commit

This commit is contained in:
2025-10-01 10:46:21 +02:00
commit 50a55e19d6
138 changed files with 2037 additions and 0 deletions

39
schleifen/aufgabe2.py Normal file
View File

@@ -0,0 +1,39 @@
import random
people = 300
a1 = 0
a2 = 0
a3 = 0
for _ in range(people):
choice = random.randint(1,3)
match choice:
case 1:
a1 +=1
case 2:
a2 += 1
case 3:
a3 += 1
case _:
pass
a1 = a1 / people * 100
a2 = a2 / people * 100
a3 = a3 / people * 100
# :.2f rundet das ergebnis auf 2 komma stellen!
# .round geht auch aber das :.2f ist effizienter hier!
print(f"""
Wahlergebnise:
---------------------
Wahl 1: {a1:.2f} %
Wahl 2: {a2:.2f} %
Wahl 3: {a3:.2f} %
---------------------
Gesamt: {a1+a2+a3:.2f} %
"""
)