7 Replies - 483 Views - Last Post: 15 October 2012 - 07:59 PM Rate Topic: -----

#1 adityamithal  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 92
  • Joined: 12-November 10

Computing interest

Posted 13 October 2012 - 07:06 AM

Month=1
x = 100
v = 5000
z = (annualInterestRate)/12 
while(balance >= 1):
   balance = v 
   while(Month <= 12):
        balance = (balance - x) * (1 + z)
        Month+=1
   x+=10    
print('Lowest Payment: ' + str(x))


The above code is not working
i am trying to find the amount which is min required to pay each moth so that the credit amount at the end of 12 months should be 0 and the amount paid monthly should be fixed

Is This A Good Question/Topic? 0
  • +

Replies To: Computing interest

#2 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 759
  • View blog
  • Posts: 2,010
  • Joined: 23-December 08

Re: Computing interest

Posted 13 October 2012 - 07:40 AM

Care to tell us what's wrong with it? Define "not working".
Was This Post Helpful? 0
  • +
  • -

#3 adityamithal  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 92
  • Joined: 12-November 10

Re: Computing interest

Posted 13 October 2012 - 07:48 AM

View Postatraub, on 13 October 2012 - 07:40 AM, said:

Care to tell us what's wrong with it? Define "not working".


compiler is not showing any output
and says error reading code
Was This Post Helpful? 0
  • +
  • -

#4 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 759
  • View blog
  • Posts: 2,010
  • Joined: 23-December 08

Re: Computing interest

Posted 13 October 2012 - 08:42 AM

We can not see your computer screen. Would you care to copy and paste the error into your reply so that we can be on the same page? If you do, please use code tags.
Was This Post Helpful? 0
  • +
  • -

#5 adityamithal  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 92
  • Joined: 12-November 10

Re: Computing interest

Posted 14 October 2012 - 05:27 PM

View Postatraub, on 13 October 2012 - 08:42 AM, said:

We can not see your computer screen. Would you care to copy and paste the error into your reply so that we can be on the same page? If you do, please use code tags.


Month=1
x = 20
v = balance
z = (annualInterestRate)/12 
i=0
while(v >= 1):
   v = balance
   Month = 1
   for i in range(12):
       v = (v - x) * (1 + z)
       Month+=1
   x+=10


x-=10
print('Lowest Payment: ' + str(x))




The above code works fine but i have to make it through bisection search.
I don`t know where to start for it
Was This Post Helpful? 0
  • +
  • -

#6 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 759
  • View blog
  • Posts: 2,010
  • Joined: 23-December 08

Re: Computing interest

Posted 14 October 2012 - 07:27 PM

do you know what bisection search is? can you describe how it works, step-by-step? Pretend I have no idea how it works.
Was This Post Helpful? 0
  • +
  • -

#7 adityamithal  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 92
  • Joined: 12-November 10

Re: Computing interest

Posted 15 October 2012 - 06:24 AM

View Postatraub, on 14 October 2012 - 07:27 PM, said:

do you know what bisection search is? can you describe how it works, step-by-step? Pretend I have no idea how it works.


step 1:
we assume 2 points 1) - lower bound
2) - Upper bound

lower bound has the lowest possible value
upper bound has the largest possible value

step 2:

we add both of them and divide by 2

step 3:

now if the possible value is in the middle ie what we get after dividing or whether it is below or above it

step 4:

if the value is above the answer then we make the answer the lower bound and the upper bound remains the same or vise-verse

step 5:

repeat these steps until found
Was This Post Helpful? 0
  • +
  • -

#8 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 759
  • View blog
  • Posts: 2,010
  • Joined: 23-December 08

Re: Computing interest

Posted 15 October 2012 - 07:59 PM

Very good, now of these steps, which ones are you unsure how to translate into code?

EDIT:
I don't understand 3 and 4... you say we do something if a certain condition is true... but you never say what we're suppose to do.

This post has been edited by atraub: 15 October 2012 - 08:00 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1