From 502f59842b38798b5730ccf09d4915bf0396c150 Mon Sep 17 00:00:00 2001 From: johanleroy Date: Mon, 8 Sep 2025 11:26:55 +0200 Subject: [PATCH] TP02 --- TP02.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/TP02.py b/TP02.py index 8e6e69e..4e14fc4 100644 --- a/TP02.py +++ b/TP02.py @@ -3,7 +3,6 @@ from decimal import Decimal, InvalidOperation, ROUND_HALF_UP THRESHOLD = Decimal('200.00') def read_amount(prompt: str) -> Decimal | None: - """Demande un montant à l'utilisateur, retourne None si 0 (arrêt).""" while True: s = input(prompt).strip().replace(',', '.') if s == '': @@ -25,20 +24,15 @@ def afficher_stats(montants: list[Decimal]) -> None: if not montants: print("\nAucun chèque saisi pour le moment.\n") return - count = len(montants) total = sum(montants) moyenne = (total / count).quantize(Decimal('0.01'), rounding=ROUND_HALF_UP) - bas = [m for m in montants if m < THRESHOLD] haut = [m for m in montants if m >= THRESHOLD] - bas_count, bas_total = len(bas), sum(bas) if bas else Decimal('0.00') haut_count, haut_total = len(haut), sum(haut) if haut else Decimal('0.00') - min_montant = min(montants) max_montant = max(montants) - print("\n--- Récapitulatif ---") print(f"Nombre de chèques : {count}") print(f"Montant total : {total} €") @@ -50,7 +44,6 @@ def afficher_stats(montants: list[Decimal]) -> None: def main(): montants: list[Decimal] = [] - print("Saisie des chèques — entre 0 pour terminer.") while True: montant = read_amount("Montant du chèque en € (0 pour terminer) : ")