-
-
Save exiva/7175931 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
balance = 5000 | |
annualInterestRate = 0.04 | |
monthlyIntr = annualInterestRate/12 | |
lo = balance/12.00 | |
hi = balance | |
guessed = False | |
while guessed == False: | |
print "Start" | |
# print "Lo: " | |
print lo | |
print hi | |
guess = (lo+hi)/2 | |
newbal = 0 | |
for i in range(0,12): | |
newbal = (newbal-(guess))*(1+monthlyIntr) | |
# print newbal | |
if newbal > 0.12: | |
lo = guess | |
# print "too low" | |
elif newbal < 0.12: | |
hi = guess | |
# print "too high" | |
# print guess | |
print "after" | |
print lo | |
print hi | |
# else: | |
# # print "got it." | |
# guessed = True | |
# break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment