Question
Suppose, you are working in a company X where your job is to calculate the profit based on their investment. If the company invests 100,000
Suppose, you are working in a company X where your job is to calculate the profit based on their investment.
If the company invests 100,000 USD or less, their profit will be based on 75,000 USD as first 25,000 USD goes to set up the business in the first place. For the first 100,000 USD, the profit margin is low: 4.5%. Therefore, for every 100 dollar they spend, they get a profit of 4.5 dollar.
For an investment greater than 100,000 USD, for the first 100,000 USD (actually on 75,000 USD as 25,000 is the setup cost), the profit margin is 4.5% where for the rest, it goes up to 8%. For example, if they invest 250,000 USD, they will get an 8% profit for the 150,000 USD. In addition, from the rest 100,000 USD, 25,000 is the setup cost and there will be a 4.5% profit on the rest 75,000. Investment will always be greater or equal to 25,000 and multiple of 100.
Please explain the how this code is working. (Explain the bolded parts only)
class FinalQ: def print(self,array,idx): if(idx
def calcProfit(self,investment): if investment <= 25000: return 0.0 else: val = investment - 100000 val = val / 100 val = val + val + val + val + val + val + val + val
return val + 3375.0
#Testing array = [25000,100000,250000,350000] f = FinalQ() f.print(array, 0)
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