Friday, November 14, 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
32399 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6765 POSTS0 COMMENTS
Nicole Veronica
11917 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11984 POSTS0 COMMENTS
Shaida Kate Naidoo
6889 POSTS0 COMMENTS
Ted Musemwa
7141 POSTS0 COMMENTS
Thapelo Manthata
6837 POSTS0 COMMENTS
Umr Jansen
6839 POSTS0 COMMENTS