Homeworks 5, Sec 2 assigned : THURS NOV 8, due THURS NOV 15.
All due times are 11:59 pm

### Using random numbers to play craps

The rules of the game: You win if you initially roll a 7 or 11, and you lose if you roll a 2 or 12. If your roll results in another number, that becomes your point. You continue to roll until you match your point, in which case you win. If you roll a 7, you lose. We wrote a program in class that simulates this game. Please see craps.py written on NOV 7. Besides main() it contains two functions, play() and rollEm() we have already used and two more that we shall explain presently.

Assume that you start with the variable amount equaling 100 and you win by reaching \$300 by betting. You do this by executing play() a number of times. This must be done in a while loop.

To this end, write two functions:

• isbroke(amount). This returns True if amount is zero, else it returns False.
• won(amount). This returns True if amount is greater than 300. Else it returns False.
.
These two functions should also print a message indicating the game status.

The main() method consist of a while loop that is executed while the player is not (broke or has won). In this loop there is another while loop in which the player is asked for her bet. This loop continues while the bet is not valid and terminates when the bet is valid. So precede the loop with valid set to False and write the while to continue while valid is false. When the bet is valid, call play(). If you win, add the bet to amount, else subtract it from amount.

Here is a sample output:

110
100
you rolled a 4
you rolled a 3
you rolled a 4
you won