def how_many_to_pick(N, M, prob):
    """
    Given a deck of N cards, M of which are marked,
    how many do you have to pick randomly without replacement
    to have at least prob probability of picking at least one marked card?
    """
for q in range(1, M + 1):
    if pick_Q(N, M, q) >= prob:
        return q
raise ValueError('Could not find a value for q')
Вытягивание карт из колоды в SciPy с помощью scipy.stats.hypergeom