二手产品经理

二手产品经理

THIS IS RENO

Learn Python Online in 100 Days - Week 3, Day 5

Record#

Catbox

  1. 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.
  2. In a for loop, you can directly write the loop without declaring a variable.
  3. Programmers commonly use i, j, and k as variables in loops, but using words with meaningful expressions may be better.
  4. 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))
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.