# Ausgabetexte: displayText_selectCategory = ( "Welche Karte(n) möchten Sie kaufen?" + "\n" + " 1 = [13€] Stehplatz" + "\n" + " 2 = [22€] Sitzplatz (Kategorie II)" + "\n" + " 3 = [30€] Sitzplatz (Kategorie I)" + "\n" + "Ihre Auswahl: " ) displayText_amountTickets = ( "Wie viele Tickets dieser Art möchten Sie kaufen? " ) displayText_addOtherTickets = ( "Möchten Sie weitere Tickets hinzufügen?" + "\n" + " 0 = Nein" + "\n" + " 1 = Ja" + "\n" + "Ihre Auswahl: " ) displayText_addStudentDiscount = ( "Sind Sie Student?" + "\n" + " 0 = Nein" + "\n" + " 1 = Ja (20% Rabatt)" + "\n" + "Ihre Auswahl: " ) displayText_shipping = ( "Welche Versandart wünschen Sie?" + "\n" + " 0 = [0€] Abholung" + "\n" + " 1 = [3€] Deutsche Post" + "\n" + "Ihre Auswahl: " ) totalPrice = 0 # Gesamtpreis (zu Beginn) while True: # Platzart und Kategorie auswählen: category = 0 # zu Beginn ungültig price = 0 # nicht notwendig, aber Konvention while category < 1 or category > 3: category = int(input("\n" + displayText_selectCategory)) if category == 1: price = 13 elif category == 2: price = 22 elif category == 3: price = 30 else: # ungültige Zahl print("\nBitte geben Sie eine gültige Zahl (1, 2, 3) ein!") # Anzahl gewünschter Karten abfragen: amount = int(input("\n" + displayText_amountTickets)) if amount < 0: amount = 0 # Fehlerbehandlung price *= amount totalPrice += price # zum Gesamtpreis hinzufügen # Zwischensumme ausgeben und evtl. weitere Karten hinzufügen print("\nZwischensumme: " + str(totalPrice) + "€") if not bool(int(input(displayText_addOtherTickets))): break # keine weiteren Karten kaufen? -> Schleife verlassen # Studentenrabatt evtl. hinzufügen isStudent = bool(int(input("\n" + displayText_addStudentDiscount))) if isStudent: totalPrice *= 0.8 # Versand wählen shipToCustomer = bool(int(input("\n" + displayText_shipping))) if shipToCustomer: totalPrice += 3 # Gesamtpreis ausgeben: print("\n" + "Gesamtpreis: " + str(round(totalPrice, 2)) + "€")