Monday, June 15, 2026
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
32516 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS