Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with a while loop
#3
Just for fun:

#annual_interest = 0.04 = 0.04 / 12 = 0.0033333333 ... per month
portion_down_payment = 30000.00
# get how much you saved + interest of 0.0033 on savings each month
def savings(cs, ms):
    accrued = cs * 1.0033  + ms
    yield accrued

#annual_interest = 0.04 = 0.04 / 12 = 0.0033333333 ... per month
portion_down_payment = 30000.00
monthly_savings = 1000
current_savings = 0
months = 0
while current_savings < portion_down_payment:
    months +=1
    current_savings = next(savings(current_savings, 1000))
    if months % 12 == 0:
        print(f'\nBeen saving for {months / 12} year(s) now, when can I move in???\n')
    print(f'months = {months}, current_savings = {round(current_savings, 2)}.')
    if (portion_down_payment - current_savings) < 1000:
        print(f'\nYou only need to pay {round(portion_down_payment - current_savings, 2)} this month and you are done!')
        print("Please borrow a lot of money from us, so we can charge you much more than 4% annual interest!")
        current_savings = portion_down_payment
Reply


Messages In This Thread
Need help with a while loop - by ampereap - May-31-2024, 01:27 AM
RE: Need help with a while loop - by deanhystad - May-31-2024, 02:36 AM
RE: Need help with a while loop - by ampereap - May-31-2024, 02:24 PM
RE: Need help with a while loop - by Pedroski55 - May-31-2024, 08:08 AM
RE: Need help with a while loop - by ampereap - May-31-2024, 02:25 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020