Question: Problem 8 . ( Gambler ' s Ruin ) Consider a coin - flipping game with two players where player one wins each toss with

Problem 8.(Gambler's Ruin) Consider a coin-flipping game with two players where player one wins each toss with prob-
ability p, and player two wins with probability q=1-p. Suppose player one has n1 pennies and player two n2 pennies.
Assuming an unfair coin (ie,p12), the probabilities p1 and p2 that players one and two, respectively, will end penniless
are
p1=1-(pq)n21-(pq)n1+n2 and p2=1-(qp)n11-(qp)n1+n2
Write a program called
gambler.py that accepts n1(int),n2(int), and p(float) as command-line arguments, and writes the
probabilities p1 and p2 to standard output, separated by a space.
_-/workspace/straightline_programs
$ python3
gambler.py 101000.51
0.66618837342006540.3338116265799349
$ python3
gambler.py 100100.51
0.0061107125105809030.9938892874894192
Problem 8 . ( Gambler ' s Ruin ) Consider a coin

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!