def calculer_CAP(montant_emprunt, taux_plafond, tx_prime, hypotheses): # Calcul de la prime prime = tx_prime * montant_emprunt print("\nCalcul de la prime: {:.2%} * {:.2f} € = {:.2f} €".format(tx_prime, montant_emprunt, prime)) # Traitement de chaque hypothèse for i, tam in enumerate(hypotheses, 1): print("\nHypothèse {} - TAM: {:.2%}".format(i, tam)) print("Prime payée en début de période: {:.2f} €".format(prime)) if tam > taux_plafond: differentiel = montant_emprunt * (tam - taux_plafond) print("Exercice de l'option car TAM > Taux plafond garanti") print("Différentiel reçu: {:.2f} €".format(differentiel)) print("Calcul du différentiel: {:.2f} € * ({:.2%} - {:.2%}) = {:.2f} €".format(montant_emprunt, tam, taux_plafond, differentiel)) else: print("Aucun différentiel reçu car TAM <= Taux plafond garanti") # Paramètres d'entrée montant_emprunt = float(input("Montant de l'emprunt : ")) taux_plafond = float(input("Taux plafond garanti (%) : ")) / 100 # Conversion en pourcentage tx_prime = float(input("Taux de la prime (%) : ")) / 100 # Conversion en pourcentage nombre_hypotheses = int(input("Nombre d'hypothèses : ")) hypotheses = [] for _ in range(nombre_hypotheses): tam = float(input("Taux d'intérêt variable (TAM) pour l'hypothèse (%) : ")) / 100 # Conversion en pourcentage hypotheses.append(tam) # Exécution du calcul calculer_CAP(montant_emprunt, taux_plafond, tx_prime, hypotheses)