Question: I wrote a code, can you check if it is correct and write four pytest for it? My pytest function is not correct. I tried

I wrote a code, can you check if it is correct and write four pytest for it?

My pytest function is not correct.

I tried to use approx since some number will turn as 100.416666666666666666666666

I wrote a code, can you check if it is correct and

def savingsByMonth (amount, interest_rate, months): Given a monthly contribution amount (e.g., 100), the annual interest rate (e.g., 5), and the number of months (e.g., 6), returns a list with the savings amount for each month, including the initial amount as the first element, and the savings in the given month as the last element. ans = [amount] total = 0 while months >0: total = (amount+total)*(1+interest rate/(100*12)) ans.append(total) months = months-1 return ans import pytest def test savingsByMonth_1(): assert savingsByMonth(100, 5, 6) == [100] def test_savingsByMonth_2(): assert savingsByMonth(100, 5, 1) == pytest. approx[100,100.41666]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!