Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started