solve this using pyhon

Viewed 27

The probability of getting n heads in a row when tossing a fair coin n times is 2^-n Implement function probability() that takes a nonnegative integer n as input and returns the probability of n heads in a row when tossing a fair coin n times.

>>> probability(1)
0.5
>>> probability(2)
0.25
0 Answers
Related