#Problem Set 1 #Name: Patrick Flynn #Collaborators: N/A #Time Spent: A Lot balance = input("Enter Outstanding Balance on your Credit Card: ") rate = input("Enter Annual Credit Card Interest Rate as a Decimal: ") def calc(ans, balance, rate): count = 0 while balance > 0: intpay = rate/12*balance balance = balance - (ans - intpay) count = count+1 return balance def minpayer(balance, rate): low = balance/12 high = round((balance*(1+(rate/12))**12)/12,2) ans = (low+high)/2 while abs(calc(ans,balance,rate)) >= .01: if calc(ans, balance, rate) < calc(low, balance, rate): low = ans ans = (low+high)/2 else: high = ans ans = (low+high)/2 print round(ans, 2) minpayer(balance, rate)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question