Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write a Python Program . Filename: craps.py Data scientists frequently develop simulations to understand how a particular system works and even to make predictions

image text in transcribed

Please write a Python Program

. Filename: craps.py Data scientists frequently develop simulations to understand how a particular system works and even to make predictions about how a system will work the future. Today, we're going to use one to play craps. Craps is my favorite casino game, although I definitely don't understand all the rules. So our simulation is going to be just for the first round of craps, during which you make a bet and roll two six-sided dice, whereupon: 1. If the sum of the two dice is 7 or 11, you win the bet! 2. If the sum of the two dice is 2, 3, or 12, you lose. :( 3. If the sum is anything else, you don't gain or lose any money. Write a simulation to play this first round of craps over and over until either (1) you run out of money, or (2) you double your money. Start with $100, and randomly choose an amount to bet on each round from $5 to $20; the bet will stay consistent throughout the entire simulation. Over and over again, roll two dice using random.randint, and determine whether you win (add the bet amount to your total), lose (subtract the bet amount from your total), or draw. Play until one of the two stopping conditions occurs, and then report back to the user: 1. How much money they ended up with 2. How many rounds were wins, losses, and draws Here's an example of our program running. As always, your output doesn't need to look exactly the same as long as it communicates the right info! You start with $100, and a bet of $17 At the end of our simulation you have... $202 Won: 18 Lost: 12 Draw: 38

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions