commit some shii
This commit is contained in:
31
csv/weihnachtslotterie/main.py
Normal file
31
csv/weihnachtslotterie/main.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import csv
|
||||
import random
|
||||
|
||||
datei = "namen.csv"
|
||||
schueler = []
|
||||
|
||||
with open(datei, newline="") as csvfile:
|
||||
reader = csv.DictReader(csvfile, delimiter=";")
|
||||
for row in reader:
|
||||
schueler.append({"Name": row["Name"], "Klasse": row["Klasse"]})
|
||||
|
||||
gewinner = random.sample(schueler, 6)
|
||||
|
||||
preise = {
|
||||
"3 Preis": gewinner[0:3],
|
||||
"2 Preis": gewinner[3:5],
|
||||
"1 Preis": gewinner[5:6]
|
||||
}
|
||||
|
||||
print("Weihnachtslotterie\n")
|
||||
print("Ausgespielt werden")
|
||||
print("1 Hauptpreis")
|
||||
print("2 Preis 2 mal")
|
||||
print("3 Preis 3 mal\n")
|
||||
|
||||
for kategorie in ["3 Preis", "2 Preis", "1 Preis"]:
|
||||
print("-" * 80)
|
||||
for person in preise[kategorie]:
|
||||
artikel = "des" if kategorie == "1. Preis" else "eines"
|
||||
print(f"Der Gewinner {artikel} {kategorie}es ist {person["Name"]} aus der {person["Klasse"]}")
|
||||
Reference in New Issue
Block a user