sympy.stats.Coin() in Python

With the help of sympy.stats.Coin() method, we can create a fair or unfair coin by using sympy.stats.Coin() method. A fair coin have the probability of Half but we can’t tell for unfair coin.
Syntax :
sympy.stats.Coin(name, value)Parameters :
Name – It stands for the name of the coin.
Value – By default it take Half and can change by using Rational value smaller than 1.Return : Return the fair or unfair coin.
Example #1 :
In this example, we can see that by using sympy.stats.Coin() method, we are able to get a fair or unfair coin by using this method.
# Import Sympy and Coin from sympy.stats import Coin, density from sympy import Rational # Using sympy.Coin method X = Coin('X') gfg = density(X).dict print(gfg) |
Output :
{H: 1/2, T: 1/2}
Example #2 :
# Import Sympy and Coin from sympy.stats import Coin, density from sympy import Rational # Using sympy.Coin method X = Coin('X', Rational(3, 5)) gfg = density(X).dict print(gfg) |
Output :
{H: 3/5, T: 2/5}



