""" x = current_savings y = portion_saved z = number_of_months """
while x < 250000:
if z >= 1 and z % 6 == 0:
x *= (100 + 4 / 12) / 100
y *= 1.07
x += y
z += 1
else:
x *= (100 + 4 / 12) / 100
x += y
z += 1
L1 = [x, z]
return L1
def rate(a, r_rate, lo, hi):
""" a = number_of_months"""
if a - 36 > 0:
lo = r_rate
r_rate = (hi + lo) / 2.0
L2 = [r_rate, lo]
return L2
else:
hi = r_rate
r_rate = (hi + lo) / 2.0
L3 = [r_rate, hi]
return L3
total_cost = 1000000
down_payment = total_cost * 0.25
annual_salary = int(input("Annual Salary"))
monthly_salary = annual_salary / 12
current_savings = 0
number_of_months = 0
low = 0.0
high = 1.0
r = 0.5
num_tries = 0
while abs(current_savings - down_payment) > 100:
portion_saved = monthly_salary * r
current_savings = 0
number_of_months = 0
L5 = [savings(current_savings, portion_saved, number_of_months)[0], savings(current_savings, portion_saved, number_of_months)[1]]
current_savings = L5[0]
number_of_months = L5[1]
L6 = [(rate(number_of_months, r, low, high)[0]), (rate(number_of_months, r, low, high)[1])]
r = L6[0]
if number_of_months - 36 > 0:
low = L6[1]
else:
high = L6[1]
num_tries += 1
print(r)
print(num_tries)