Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''Tengo esta tarea, se definieron 3 variables (balance, annualInterestRate y monthlyPaymentRate). Es para calcular cuanto se habra pagado de un prestamo al final de un aƱo, si se paga con la tasa mas baja. En este caso los valores de prueba son: balance = 5000, annualInterestRate = 0.18 y monthlyPaymentRate = 0.02
- El output es asi:
- Month: 1 (para cada mes)
- Minimum monthly payment: 96.0 (para cada mes)
- Remaining balance: 4784.0 (para cada mes)
- Total paid: 96.0 (al final del programa)
- Remaining balance: 4784.0 (al final del programa)
- En el idle me corre bien y genera los datos pero en el sistema de edx me da error.'''
- #Opcion1
- month = 1
- totalPaid = 0
- for month in range(1,12):
- minMonthlyPayment = monthlyPaymentRate * balance
- interest = (balance - minMonthlyPayment) * (annualInterestRate / 12)
- updatedMonthlyBalance = balance + interest - minMonthlyPayment
- print('Month: ' + str(month))
- print('Minimun monthly payment: ' + str(round(minMonthlyPayment,2)))
- print('Updated balance each month: ' + str(round(updatedMonthlyBalance,2)))
- month += 1
- totalPaid += minMonthlyPayment
- balance = updatedMonthlyBalance
- print('Total paid: ' + str(round(totalPaid, 2)))
- print('Remaining balance: ' + str(round(updatedMonthlyBalance, 2)))
- #Opcion2
- def ccbalance(balance, annualInterestRate, monthlyPaymentRate):
- month = 1
- totalPaid = 0
- while month < 13:
- minMonthlyPayment = monthlyPaymentRate * balance
- interest = (balance - minMonthlyPayment) * (annualInterestRate / 12)
- updatedMonthlyBalance = balance + interest - minMonthlyPayment
- print('Month: ' + str(month))
- print('Minimun monthly payment: ' + str(round(minMonthlyPayment,2)))
- print('Updated balance each month: ' + str(round(updatedMonthlyBalance,2)))
- month += 1
- totalPaid += minMonthlyPayment
- balance = updatedMonthlyBalance
- print('Total paid: ' + str(round(totalPaid, 2)))
- print('Remaining balance: ' + str(round(updatedMonthlyBalance, 2)))
Add Comment
Please, Sign In to add comment