Menu
Coddy logo textTech

Formatierte Ausgabe

Teil des Abschnitts Fundamentals der Python-Journey von Coddy — Lektion 34 von 77.

challenge icon

Aufgabe

Anfänger

Der letzte Schritt dieses Projekts besteht darin, die Ausgabe zu formatieren!

Zum Beispiel für die folgende Eingabe:

100 #bill
5 #tip percent
2 #number of people

Ausgabe im folgenden Format:

Bill Split Calculator
Total (including tip): $105.0
Each person pays: $52.5

Wichtige Formatierungshinweise:

  • Die Ausgabe sollte exakt so sein wie gezeigt, einschließlich aller Großbuchstaben und Symbole
  • Runden Sie die Zahlen nicht - verwenden Sie Pythons Standard-Float-Formatierung (kein .2f oder ähnliches)
  • Wenn Zahlen in den Typ float konvertiert werden, zeigt Python sie mit unterschiedlichen Dezimalstellen an (z. B. 105.0, 52.5, 164.28571428571428)
  • Verwenden Sie f-Strings, um die berechneten Werte direkt einzufügen: f"${variable_name}"

Probier es selbst

print("Bill Split Calculator")

bill_amount = float(input())
tip_percentage = float(input())
num_people = int(input())

tip_amount = (tip_percentage / 100) * bill_amount
total_amount = bill_amount + tip_amount
amount_per_person = total_amount / num_people

print(total_amount)
print(amount_per_person)

Alle Lektionen in Fundamentals