Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Simulate the game of Craps using Python. Write a program that plays 10 rounds of Craps, tracking how many times the player wins and the

Simulate the game of Craps using Python. Write a program that plays 10 rounds of Craps, tracking how many times the player wins and the dealer wins.

The rules of craps are as follows:

The player rolls a pair of 6-sided dice and the value of the 2 dice are displayed to the user.

If the sum of dice is 7 or 11 on the first throw, the player wins the round.

If the sum of dice is 2, 3 or 12, the dealer wins the round.

Any other sum becomes "the points". To win the round, the player must continue rolling the dice until a roll matches "the points". This is termed "making the points". If the player rolls a 7 before making the points, the dealer wins the round.

I need help with coding where Im told to Now add to the code the situation when a 2, 3, 7, 11, or 12 have not been rolled. Finally, have the game run ten times. Lastly, keep track of how many times the player and the dealer win the game.

Is my code correct? I'm not sure if I did the while loop correctly?

questiontotheplayer= input("Do you want to play craps(y/n)?")

while questiontotheplayer == "y":

toplay= input("Press enter to roll the dice!")

firstroll = random.randint(1,6) + random.randint(1,6) #sum of the dice

print ("You rolled a",firstroll)

if firstroll == 7 or firstroll == 11:

print("Player Won!")

elif firstroll == 2 or firstroll == 3 or firstroll == 12:

print("Dealer Won, You Lost")

else:

print(" We're going to try to roll the point!")

point = firstroll

newthrow = random.randint(1,6) + random.randint(1,6)

print("You rolled a", newthrow)

while newthrow != point and newthrow !=7:

toplay= input("Press enter to try to roll the point!")

newthrow = random.randint(1,6) + random.randint(1,6)

print("You rolled a", newthrow)

if newthrow == point:

print("Player Won!")

else:

print("Dealer Won, You Lost")

question2totheplayer= input("Do you want to play again (y/n)?")

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

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

More Books

Students also viewed these Databases questions

Question

What must a creditor do to become a secured party?

Answered: 1 week ago

Question

When should the last word in a title be capitalized?

Answered: 1 week ago

Question

=+ d. a professor deciding how much to prepare for class

Answered: 1 week ago