def pick_Q(N, M, Q):
    """
    Given a deck of N cards, where M are marked,
    and Q cards are taken randomly without replacement,
    return the probability that at least one marked card is taken.
    """
return 1.0 - scipy.stats.hypergeom.pmf(0, N, M, Q)
Drawing cards from a deck in SciPy with scipy.stats.hypergeom