Craps game in Python

Hi, I’m Raul Ramirez, and this is the lab 15 problem, one craps game, it’s pretty short, so, let’s get to it. Basically, we just need to understand what we need to achieve to win the way that I figured how to get into the program, putting together the if statements. So here we have a pseudo code.

If the first roll is 7 or 11, you win. Otherwise, if it’s a 2, 3 or 12, you lose and keep in mind it’s on the first roll and keeping additional rolls in mind until you basically win or lose you win. If you roll, the same number twice: lose if you roll a 7 after the first roll.

So essentially you roll you get a 4 and then you got a 4 again. Then you win or 4. Then you get a 7. You lose pretty simple. So we need to achieve a couple things and we need to use a function from the random library to simulate a die, create a roll function that is called on by a main function for the game.

It’S craps so make sure the player rolls the dice. We’Re asked to add bets, or maybe some exception handling or something to make it more fun, but I’ve got other finals, so I used the random import. Rand int makes a little easier because it picks an integer from 1 to 100. As you can see Rand int 1 through 6. It’S simulating 6 sides, so it could be 1 through 6. I went ahead and call a roll function to roll two dice, since each time roll is called it’s an individual die, so it kind of didn’t make sense writing it ended up double lines or triple lines or whatever just keeping one line at it and spit it Out, obviously, we don’t just want it to run.

We just want some interaction in there, so putting in a request string which takes players response to play or not would start. The game show whether or not the rules of the game apply, which in this case they will because the whole point behind craps and essentially, if the player wants to roll a die, it just keeps rolling in every roll. Just one dice the one that you roll. Both dice and then just keep rolling you achieve that with a while loop, so you either reach it win, condition or a loose condition, and then you break the while loop that way.

Yeah it says pretty it’s pretty much. It