Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i was asked to write pytest by myself But it fails. I would appreciate if you can help. def savings ByMonth(amount, interest rate, months): Given

i was asked to write pytest by myself
But it fails. I would appreciate if you can help. image text in transcribed
image text in transcribed
def savings ByMonth(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> : total = (amount+total)*(1+interest rate/(100*12)) ans.append(total) months = months-1 eturn ans import pytest def test savingsByMonth 10: assert savingsByMonth(100, 5, 0) == (100) def test savingsByMonth 20: assert savingsByMonth (100, 5, 1) - pytest.approx[100, 100.41666) ======== FAILURES EEEEEEEE test_savingsByMonth_2_ def test_savingsByMonth_2(): assert savingsByMonth(100, 5, 1) == pytest. approx[100,100.41666) TypeError: function' object is not subscriptable Lab_04.py:60: TypeError mm 1 failed, 6 passed in 0.05 seconds

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

1st Edition

1597496251, 978-1597496254

More Books

Students also viewed these Databases questions