We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Profit Function

Let's write the profit function for our bakery example in code. It's calculated as:

  • 5 units of currency per chocolate cake sold, plus
  • 1 unit of currency per sugar cookie sold.

Constraints:

  • At most 250 chocolate cakes can be sold per day.
  • At most 200 sugar cookies can be sold per day.
  • At most 300 total desserts can be produced per day.

Calculating profit for any given balance of sales is not the same as finding the optimal quantities to maximize profit. We'll talk more about that later.

Assignment

Complete the calculate_profit function. It accepts num_cakes and num_cookies parameters, and returns total profit as an integer.