USE PYTHON ONLY
Please write a Python program to let you or the user play the game of rolling 2 dice and win/lose money. Initially, you have 100 dollars in your account, and the dealer also has 100 dollars in his/her account. You would be asked to enter a bet to start the game. If your bet is zero, the game would be stopped immediately. Otherwise, dealer would roll 2 dice and get a number from ( random.randint(1, 6) + random.randint(1, 6) ). You would roll 2 dice and get a number from ( random.randint(1, 6) + random.randint(1, 6) ). Now, compare your number with the dealer’s number to see who would won the bet amount and who would lose the bet amount. If you lose, the bet would be deducted from your account, and the same bet would be added to the dealer’s account. If you won, the bet would be added to your account, and the same bet would be deducted from the dealer’s account. If it’s a tie, neither your account nor dealer’s account would be touched. Then, continue the game with the same bet amount automatically until either your account or dealer’s account has a zero or negative balance. Then, show the final result of both accounts’ balance, and stop the game. Please note that you must not get a number from random.randint(2, 12) because ( random.randint(1, 6) + random.randint(1, 6) ) is more random and fair to roll 2 dice between the dealer and you. You must test your game program 3 times. Your test case #1 should look as follows. You must also do test case #2 and test case #3 with different data.
Welcome to the Rolling 2 Dice Game of TM
1 ============================================================.
Now, you have 100 dollars to play the game. Dealer also has 100 dollars.
>> Enter your bet to roll 2 dice for this complete game (enter 0 to quit):50
2 ============================================================.
Roll 2 dice twice: Dealer got 5 , and you got 6 .
You won. Now, you have 150 dollars, and dealer has 50 dollars.
3 ============================================================.
Roll 2 dice twice: Dealer got 4 , and you got 11 .
You won. Now, you have 200 dollars, and dealer has 0 dollars.
4 ============================================================.
Game ends. You have 200 dollars, and dealer has 0 dollars.
5 ============================================================.
Thank you for playing this Rolling 2 Dice Game of TM!
6 ============================================================.
Python is indentation specific. Please maintain the tab spaces as they are in the code screenshot.
Code:
import random
dealer_mny=100
your_mny=100
print("Welcome to the Rolling 2 Dice Game of TM")
print("Now, you have 100 dollars to play the game. Dealer also has
100 dollars.")
dealer_dice=-1
your_dice=0
count=0
while(True):
if(count==0):
inp = int(input("Enter your bet to roll 2 dice for this complete
game (enter 0 to quit):"))
count = count+1
if(inp==0):
break
dealer_dice=random.randint(1, 6) + random.randint(1, 6)
your_dice=random.randint(1, 6) + random.randint(1, 6)
print("Roll 2 dice twice: Dealer got",dealer_dice,"\b, and you got"
,your_dice ,".")
if(dealer_dice<your_dice):
your_mny = your_mny+inp
dealer_mny = dealer_mny-inp
print("You won. Now, you have",your_mny," dollars, and dealer
has",dealer_mny, " dollars.")
elif((dealer_dice>your_dice)):
your_mny = your_mny-inp
dealer_mny = dealer_mny+inp
print("Dealer won. Now, you have", your_mny," dollars, and dealer
has", dealer_mny, "dollars.")
if(your_mny<=0 or dealer_mny<=0):
print("Game ends. Now, you have", your_mny,"dollars, and dealer
has",dealer_mny,"dollars.")
break
print("Thank you for playing this Rolling 2 Dice Game of
TM!")
code screenshot:
output:
USE PYTHON ONLY Please write a Python program to let you or the user play the...
Please write the program in python: 3. Design and implement a simulation of the game of volleyball. Normal volleyball is played like racquetball, in that a team can only score points when it is serving. Games are played to 15, but must be won by at least two points. 7. Craps is a dice game played at many casinos. A player rolls a pair of normal six-sided dice. If the initial roll is 2, 3, or 12, the player loses....
Please i need helpe with this JAVA code. Write a Java program simulates the dice game called GAMECrap. For this project, assume that the game is being played between two players, and that the rules are as follows: Problem Statement One of the players goes first. That player announces the size of the bet, and rolls the dice. If the player rolls a 7 or 11, it is called a natural. The player who rolled the dice wins. 2, 3...
For this lab you will write a Java program that plays the dice game High-Low. In this game a player places a bet on whether the sum of two dice will come up High (totaling 8 or higher), Low (totaling 6 or less) or Sevens (totaling exactly 7). If the player wins, they receive a payout based on the schedule given in the table below: Choice Payout ------ ------ High 1 x Wager Low 1 x Wager Sevens 4 x...
Write a c++ program that simulates a million of games in craps. I am having a trouble getting to loop a million of times. I am trying to use a const for a million. This is the code so far. #include <iostream> #include <cstdlib>// contains prototypes for functions srand and rand #include <ctime>// contains prototype for function time #include <iomanip> using namespace std; int rollDice(); // rolls dice, calculates and displays sum void printstats(); int totroll = 0, games, point,...
You are on a TV show. You have been asked to either play a dice game or accept a $50 bill. The dice game works like this: You roll four dice. For each dice; if you roll a 1, 2, or 3, you win $60. If you roll a 4 or 5, you lose $30. If you roll a 6, you lose $70. Determine expected value of the dice game? Do you play the game, or take the money? Explain...
A street hustler offers you the following game: Each play you roll 2 dice. Each play costs $1 If you roll an even number you win that amount If you roll an odd number you lose that amount in addition to the $1. 1) Calculate the probabilities P(X 1+X 2-3) 2) write the reward function, rie), where s -X + X, in the following form r(e)-a 3) What is the expected reward? Should you take up the bet?
You play a game in which you roll a number n of dice. You win if you roll at least one 6, but no 1s or 2s; and, otherwise, you lose. What is the optimal number of dice to roll in this situation? Choose the best answer. A) 1 B) 2 C) 3 D) 4
Java Program Note: no break statements or switch staements High, Low, Sevens For this lab you will write a Java program that plays the dice game High-Low. In this game a player places a bet on whether the sum of two dice will come up High (totaling 8 or higher), Low (totaling 6 or less) or Sevens (totaling exactly 7). If the player wins, they receive a payout based on the schedule given in the table below: Choice Payout ------...
in C++ This assignment is to use your knowledge of Chap 1-5 to write a simulation program to estimate the winning chance of the Craps game. Craps is a popular dice game played in casinos. Here is how to play: Roll two dice. Each die has 6 faces representing values 1,2,3,4,5,and 6, respectively. Check the sum of 2 dice. If the sum is 2, 3, or 12 (called craps), you lose; if the sum is 7 or 11 (called natural),...
You will write a two-class Java program that implements the Game of 21. This is a fairly simple game where a player plays against a “dealer”. The player will receive two and optionally three numbers. Each number is randomly generated in the range 1 to 11 inclusive (in notation: [1,11]). The player’s score is the sum of these numbers. The dealer will receive two random numbers, also in [1,11]. The player wins if its score is greater than the dealer’s...