← Back to challenges

Profitable Gamble

PythonMediummathvalidationconditions

Instructions

Create a function that takes three arguments prob, prize, pay and returns True if prob * prize > pay; otherwise return False.

To illustrate:

profitable_gamble(0.2, 50, 9)

... should yield True, since the net profit is 1 (0.2 * 50 - 9), and 1 > 0.

Examples

profitable_gamble(0.2, 50, 9) ➞ True

profitable_gamble(0.9, 1, 2) ➞ False

profitable_gamble(0.9, 3, 2) ➞ True

Notes

A profitable gamble is a game that yields a positive net profit, where net profit is calculated in the following manner: net_outcome = probability_of_winning * prize - cost_of_playing.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Check if an Integer is Divisible By Five