# Day 019 - Project 19 : Loan Calculator

If you have any questions, comments or issues with this project please post them here!

1 Like

Built an interest calculator to see how much money I would owe! A bit boring, I know, but necessary for #reallife.

Day 19 of #Replit100DaysOfCode #100DaysOfCode.

1 Like

Not sure how best to notify the group who puts the videos together. In the video for Day 19, at approximately the 1:22 mark, David says â€śâ€¦that help us loop, and create variables aâ€ť and then the video cuts to the graphic for Up Next : Range

4 Likes

Iâ€™m stuck at this challenge and need help.

https://replit.com/@wittphoonsiri/day-19100-days

I manage to find a method to replicate the answers as shown by David but canâ€™t figure how to turn it into a code. I feel there are some necessary process or info that isnâ€™t cover in Davidâ€™s lesson video:

Can anyone help me please? I feel my process is wrong. I end up having to use exit( ) to end the loop as it will run 10 times of the same stuff.

This is Davidâ€™s request:

You are going to create a loan calculator that shows how much money you owe for a loan of \$1,000 with a 5% APR (APR is fancy for Annual Percentage Rate) over 10 years.

This means each year the amount of money you owe will increase 5%.

Figure out how much you owe altogether for 10 years?

Use a `for` loop and one or two lines of looped code to determine the answer. (Hint: Donâ€™t make this overcomplicated. It should only be a few lines of code altogether.)

``````print("Loan Calculator")
print("\$1000 over 10 years at 5% APR")
for initial_value in range(10):
initial_value = float(input("Enter initial value: "))
annual_percentage_rate = float(input("Enter APR value: "))
year = float(input("Enter amount of year: "))
interest1 = (initial_value * annual_percentage_rate)+ initial_value
print("year1 is", interest1)
interest2 = (interest1 * annual_percentage_rate)+ interest1
print("year2 is", interest2)
interest3 = (interest2 * annual_percentage_rate)+ interest2
print("year3 is", interest3)
interest4 = (interest3 * annual_percentage_rate)+ interest3
print("year4 is", interest4)
interest5 = (interest4 * annual_percentage_rate)+ interest4
print("year5 is", interest5)
interest6 = (interest5 * annual_percentage_rate)+ interest5
print("year6 is", interest6)
interest7 = (interest6 * annual_percentage_rate)+ interest6
print("year7 is", interest7)
interest8 = (interest7 * annual_percentage_rate)+ interest7
print("year8 is", interest8)
interest9 = (interest8 * annual_percentage_rate)+ interest8
print("year9 is", interest9)
interest10 = (interest9 * annual_percentage_rate)+ interest9
print("year10 is", interest10)
print("You paid \$628.89 in interest!")
exit()
``````

Why are you even looping? just get rid of the loop

Because Davidâ€™s instruction is for me to â€śUse a for loop and one or two lines of looped code to determine the answerâ€ť: He also hinted:

• Make sure the `for` loop happens 10 times.
• Start your value (amount you are borrowing) before the loop starts.
• If you need to count on one more number, just write `i+` in the `print` statement to tell the computer to add the next number"

https://replit.com/@wittphoonsiri/day-19100-days#main.py

The loop is for recalculating the interests every year.
Also, you need to leave the inital values, any input, outside of the loop because it should only be asked for one time.
Therefore, your code should look like this:

``````print("Loan Calculator")
print("\$1000 over 10 years at 5% APR")
interest = initial = float(input("Enter initial value: "))
annual_percentage_rate = float(input("Enter APR value: "))
years = float(input("Enter amount of year: "))

for year in range(years):
interest *= annual_percentage_rate
print(f"Year {year + 1}: {interest}")
print(f"You paid \${initial - interest} in interest!")
``````
3 Likes

My code is simple (there insâ€™t any input) but I think itâ€™s correct. Check it out!

### Problem description

Question is bug solve the following:

``````total = 0
for number in range 100:
total += number
print(total)
``````

Anwser given by Replit is the following: Add ( ) to 100

``````total = 0
for number in range (100):
total += number
print(total)
``````

### Expected behavior

This should print number 0 to 99

### Actual behavior

Print 0 to 4950 because

### Steps to reproduce

Go to replit learn Go 100 days python day 19

chrome

windows

n/a

### Plan

free

Hi @royvlasman , welcome to the forums!
Try entering `kill 1` in the Shell to reboot the environment.

1 Like

I see the confusion, the example isnâ€™t supposed to simply count up by 1 until it reaches 100. Itâ€™s supposed to add all of the numbers from 0 to 99 together.

0 + 0 = 0
0 + 1 = 1
1 + 2 = 3
3 + 3 = 6
6 + 4 = 10

and so on all the way until it reaches `+ 99`

The program is behaving as itâ€™s supposed to.

To make it clearer that that is whatâ€™s happening you can try this instead

``````total = 0
for number in range(100):
oldtotal = total
total += number
print(oldtotal, "+", number, "=", total)
``````

3 Likes