Thursday, October 9, 2025
HomeLanguagessympy.stats.Coin() in Python

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}
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32346 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6714 POSTS0 COMMENTS
Nicole Veronica
11877 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11940 POSTS0 COMMENTS
Shaida Kate Naidoo
6835 POSTS0 COMMENTS
Ted Musemwa
7094 POSTS0 COMMENTS
Thapelo Manthata
6789 POSTS0 COMMENTS
Umr Jansen
6791 POSTS0 COMMENTS