Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i keep getting the error, NameError: name 'calculate_gains' is not defined. i attached 2 versions of the code i have so far. What you need

i keep getting the error, NameError: name 'calculate_gains' is not defined.
i attached 2 versions of the code i have so far.
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
What you need to do, part 2 Another functionality for the app is the ability to estimate the return on investment over a period of time. In order to implement this feature, you will have to update the investment calculator algorithm. The base function to calculate the return on investment from Task 1 can be reutilized here to simplify our task. This feature will take into consideration a 12-month period by default. To calculate the total amount earned over a period of time, you will have to loop through the n-months period, increase the amount for each period. The other rules from the previous task apply here as well. For example: If you invest $3 million on the first month, and obtain a return of $93.000 dollars, then the amount to be invested in the second month is $3.093 million. To summarize: - Loop over a period of 12 months to calculate the total for each period - Return the accumulated estimated value for a period of 12 months As the algorithm performs division of numbers with high precision, it is very common to see really big numbers after the period (for example: 1200.2300001 ), which is not desirable because of several reasons: 1. may cause confusion to some users when they see such big numbers; 2. uses more memory to store a bigger number: 3. it just does not make sense to display currency number in this format. For this reason, you are going to implement a utility function to format any number into the appropriate curiency format, using 2 decimal places. For example: The number 1200.2300001 would be became: 1200.23 Take a look at the formatting options for python native. ef calculate gains over_time(amount_inv =0.0, period =12) : Mini Calculating the return gains of a given amount invested based on a period : param amount inv: the money amount invested iparam period: application period ireturn: (nain) A call the base calculate-gains function to estimate the gains for the : \# calculate the first period before entering the 100 p \#loop through the specified period to calculate the gain of each month I 1 to period-1 because the first period gains is already calculated abovi \# call the function to update the value based on the period inside the new_amount = total_amount H update the new_amount variable H return the final anmount return new amount print (calculate-gains over_time (anount inv =4000000, period =12 ))

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 Design And Relational Theory Normal Forms And All That Jazz

Authors: Chris Date

1st Edition

1449328016, 978-1449328016

More Books

Students also viewed these Databases questions

Question

What is your view of spirituality in the workplace?

Answered: 1 week ago