Record#
- Today I learned a new way of looping, the for loop. This type of loop is suitable for situations where the number of iterations is known.
- In a for loop, you can directly write the loop without declaring a variable.
- Programmers commonly use i, j, and k as variables in loops, but using words with meaningful expressions may be better.
- Today's code is a loan calculator. Overall, there are no major issues, but I still don't understand calculations like +=.
CODE#
print("Loan Calculator")
print()
n1 = int(input("Please enter your loan amount: "))
n2 = int(input("Please enter your interest rate: "))
n3 = int(input("Please enter your loan term: "))
total = n1
print()
print("Your loan amount is:", n1, ", your loan term is:", n3, ", your interest rate is:", n2, "%")
print()
for years in range(n3):
n1 += n1 * n2 / 100
print("In year", years + 1, ", your repayment amount is:", round(n1, 2), "and the interest amount is:",
round((n1 - total), 2))