Solving Algorithmic Problems in Python with Pytest (2019)
How would you write tests for the following problem with random output?<p>Write a function biasedcoin(n,p) that takes the number of coin flips, n, and the probability of heads, p. It flips a biased coin n times, and returns the ratio of number of heads&#x2F;number of tails. p is guaranteed to have two significant numbers eg. p = 0.60 or p = 0.74. You should use the random.randrange function to generate random numbers.<p>Example implementation<p>def biasedcoin(n,p):<p><pre><code>    import randrange from random

    heads = tails = 0

    for i in range(n):

        if randrange(100) &lt; 100*p:

            heads += 1

        else:

            tails += 1

    return heads&#x2F;tails</code></pre>