Marketing Costs

Implement the desired_marketing_expenditure function, which returns the required amount of money that needs to be invested in a new marketing campaign to sell the desired number of units.

Use the data from previous marketing campaigns to evaluate how the number of units sold grows linearly as the amount of money invested increases.

For example, for the desired number of 60,000 units sold and previous campaign data from the table below, the function should return the float 250,000.

Previous campaigns

Campaign Marketing expenditure Units sold
#1 300,000 60,000
#2 200,000 50,000
#3 400,000 90,000
#4 300,000 80,000
#5 100,000 30,000
Python 3.10.5, Pandas 1.4.3, Numpy 1.22.4, Scipy 1.8.1, Scikit-learn 1.1.1


  • Python for Data Science
  • Linear Regression
  • Machine Learning
  • NumPy
  • Scikit-Learn
  • Public
  • Hard


Difficulty: Hard

Duration: 30 min

Author: Tonći Kokan

Score Distribution

% of candidates

Would you like to see our other questions?

We have 1000+ premium hand-crafted questions for 160+ job skills and 20+ coding languages. We prefer questions with small samples of actual work over academic problems or brain teasers.

Would you like to see our tests?

The following tests contain Python for Data Science related questions:

On the blog

Since we're all biased and we use incorrect proxies, why not just outsource hiring to experts or recruitment agencies? After all, they've been screening people for many years, so they must know how to do it right?

Not really. I was surprised to discover that many experts...