Lottery Profitability Check

A Pyhon function to determine the profitability of a lottery ticket purchase based on winning probability, prize amount, and ticket cost.

The task at hand involves the creation of a Python function to determine if a lottery ticket buying strategy is profitable. Profitability is evaluated based on three parameters: winning probability, prize value, and ticket cost. The function should accept three parameters, `prob`, `prize`, and `pay`, where `prob` denotes the probability of winning, `prize` denotes the cash prize value and `pay` denotes the ticket cost. The function should return `True` when the expected gain (`prob * prize`) is over the ticket cost (`pay`), and `False` otherwise. **Note**: For example, when evaluated solution(0.2, 50, 9), it should return True, since (0.2 * 50 - 9) > 0. ### Parameters - `prob` (float): Refers to the probability of winning the lottery. - `prize` (float): Denotes the cash prize value of the lottery. - `pay` (float): Symbolizes the cost incurred on buying a lottery ticket. ### Return Value - Returns `True` if the calculated value `prob * prize` is more than the value `pay`. - Returns `False` otherwise. ### Examples ```python # The expected gain (0.2 * 50 = 10) is more than the ticket cost (9) solution(0.2, 50, 9) # True # The expected gain (0.9 * 1 = 0.9) is less than the ticket cost (2) solution(0.9, 1, 2) # False # The expected gain (0.9 * 3 = 2.7) is more than the ticket cost (2) solution(0.9, 3, 2) # True ``` ```