二手产品经理

二手产品经理

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 in advance.
  2. The for loop can be used without declaring variables, you can write them directly in the loop.
  3. Programmers commonly use i, j, and k as loop variables, using words with meaningful expressions might be better.
  4. Today's code writing program is an interest calculator, overall there are no major issues, but I still don't quite understand calculations like +=.

CODE#

print("Repayment Calculator")
print()
n1 = int(input("Enter your loan amount: "))
n2 = int(input("Enter your interest rate: "))
n3 = int(input("Enter your loan term in years: "))
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), "Interest amount is: ",
          round((n1 - total), 2))
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.