Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

Draft a proposal for a risk assessment exercise.

Answered: 1 week ago