in Education by
SA=1000.00 AI=0.12 MP=100.00 def remainb(x): if x==0: return 0 else: return x=(SA+(AI/12)*SA)-MP for i in range(x,1000000): x=(x+(AI/12)*x)-MP CIwoP=(x+(AI/12)*x)-x #interest every month ptd=MP*i#payment to date #ptdreal=(ptd-CIwoP) #rbal=(CIwP-ptd) print(i)#payment no. print(ptd)#amount paid to date print(CIwoP)#interest for that month print(x)#balance for each month after payment #if rbal==0: return 0 #return Made multiples attempts at debugging but failed repeatedly for hours. Frankly, I am stuck. If anyone can give me any advice on how to approach this problem (eg. run the loop until SA==0). Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
You are trying to Switching to while loop is more appropriate as you are not sure how many times you need to loop. This will continue as long as x greater than 0. x = (SA + (AI / 12) * SA) - MP payment_number = 0 while x > 0: x = (x + (AI / 12) * x) - MP CIwoP = (x + (AI / 12) * x) - x # interest every month ptd = MP * payment_number # payment to date payment_number += 1 print(payment_number) # payment no. print(ptd) # amount paid to date print(CIwoP) # interest for that month print(x) # balance for each month after payment Recursion approach def remainb(x, payment_number=0): if x < 0: return x = (x + (AI / 12) * x) - MP CIwoP = (x + (AI / 12) * x) - x # interest every month ptd = MP * payment_number # payment to date payment_number += 1 print(payment_number) # payment no. print(ptd) # amount paid to date print(CIwoP) # interest for that month print(x) # balance for each month after payment remainb(x, payment_number) If you are a beginner and want to know more about Python the do check out the data science with python course

Related questions

0 votes
    If I use a while loop for my below code, it is not giving the desired output, but when i use for loop i am anle ... x += 1 print(Comm) Select the correct answer from above options...
asked Jan 9, 2022 in Education by JackTerrance
0 votes
    Here's the code: ''' file_path = (r'C:\Users\Luka\Desktop\Pyhton exercises\pi_digits.txt') with open( ... file_object: print(line) Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I have a big data frame. I want to replace float 1.0 and 0.0 with the true and false. My code: import pandas ... to do it in one line. Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    To the data frame df: Player Team Points Mean Price Value Gameweek 1 Jim Leeds 4.4 4.40 10.44 0.44 2 Jim ... scalar What am I missing? Select the correct answer from above options...
asked Jan 18, 2022 in Education by JackTerrance
0 votes
    I have the function and want to create a new column df['growth_factor'] which will have a derived value in it. ... can I achieve this? Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I am totally new to Machine Learning and I have been working with unsupervised learning technique. Image shows my ... 3 were given Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    I want to upload the file pdf to the folder but a file is not saved to a folder. I already read the ... .run(debug=True)``` Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I have the dataset that has the no_employees column that is the str object. whats is a best way to create the new ... 1-5 |Very Small Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    When I run pip3 install -r requirements.txt on the project I get this error message: pip._vendor.pkg_resources. ... on my machine. Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    please see my code below, example_list = [ ['a','b','c'], ['f','g','h'], ['i','j','k'], ] my_string = ''' ' ... g','h'), ('i','j','k'); Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I have the data frame that looks like this: Date Visa Mastercard Amex Paypal 1/1/20 0 20 0 0 2/1/20 ... info() Any help is appreciated Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    A few days ago I've started learning pygame. So, now I've got the code which allows me to draw different ... ) py.display.update() Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    Can anyone tell me what is Python with Data Science? Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    I have this following datetime64[ns] type timestamps. x1=pd.Timestamp('2018-04-25 00:00:00') x2=pd.Timestamp('2020- ... -04-25 00:53:00 Select the correct answer from above options...
asked Jan 9, 2022 in Education by JackTerrance
0 votes
    It is a principal question, regarding the theory of neural networks: Why do we have to normalize the input for ... is not normalized? Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
...