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} % """ )