In the game of Lucky Sevens, the player rolls a pair of dice. If the dots add up to 7, the player wins $4; otherwise, the player loses $1. Suppose that, to entice the gullible, a casino tells players that there are many ways to win: (1, 6), (2, 5), and soon. A little mathematical analysis reveals that there are not enough ways to win to make the game worthwhile; however, because many people's eyes glaze over at the first mention of mathematics “wins $4”.
Your challenge is to write a program in python that demonstrates the futility of playing the game. Your Python program should take as input the amount of money that the player wants to put into the pot, and play the game until the pot is empty.
The program should have at least TWO functions (Input validation and Sum of the dots of user’s two dice). Like the program 1, your code should be user-friendly and able to handle all possible user input. The game should be able to allow a user to ply several times.
The program should print a table as following:
Number of rolls Win or Loss Current value of the pot
1 Put $10
2 Win $14
3 Loss $11
4
## Loss $0
You lost your money after ## rolls of play.
The maximum amount of money in the pot during the playing is $##.
Do you want to play again?
At that point the player’s pot is empty (the Current value of the pot is zero), the program should display the number of rolls it took to break the player, as well as maximum amount of money in the pot during the playing.
import random
# function to roll 2 die and return the result of sum of those die
def rollDie():
return(random.randint(1,6) + random.randint(1,6))
def main():
while True: # loop that continues till the user wants
pot = int(raw_input('Enter the money in the pot : $')) # input of initial pot
rolls = 0
maxPot = pot
print('%20s %20s %s'%('Number of rolls','Win or Loss','Current value of the pot'))
# loop that continues till the pot is non-empty
while pot > 0:
rolls = rolls + 1
result = rollDie()
# check the result
if result == 7:
pot = pot + 4
print('%20d %20s %10s' %(rolls,'Win','$'+str(pot)))
else:
pot = pot - 1
print('%20d %20s %10s' %(rolls,'Loss','$'+str(pot)))
if pot > maxPot: #check for maxPot
maxPot = pot
#print the result
print('Took %d rolls to empty the pot' %(rolls))
print('Maximum pot : $%d' %(maxPot))
cont = raw_input('Do you want to continue ? (y/n) ')
if cont.lower() == 'n':
break
#call the main function
if _name_ == "__main__":
main()

In the game of Lucky Sevens, the player rolls a pair of dice. If the dots...
Instructions sevens.py 1 # Put your code here In the game of Lucky Sevens, the player rolls a pair of dice. If the dots add up to 7, the player wins $4; otherwise, the player loses $1. Suppose that, to entice the gullible, a casino tells players that there are lots of ways to win: (1,6), (2,5), and so on. A little mathematical analysis reveals that there are not enough ways to win to make the game worthwhile; however, because...
2. "Craps" is a game played by rolling two fair dice. To play one round of this game, the player rolls the dice and the outcome is determined by the following rules: If the total number of dots is 7 or 11 (a "natural"), then the player wins. If the total number of dots is 2, 3, or 12 C'craps"), then the player loses. If the total number of dots is 4, 5, 6,8,9, or 10, then this number is...
The game of Pig is a simple two-player dice game in which the first player to reach 100 or more points wins. Players take turns. On each turn, a player rolls a six-sided die: If the player rolls a 1, then the player gets no new points and it becomes the other player’s turn. If the player rolls 2 through 6, then he or she can either ROLL AGAIN or HOLD: At this point, the sum of all rolls...
In a dice game, the player independently rolls a fair red die and a fair green die.The player wins if and only if the red die shows a 1, or 2, or 3, or if the total on the two dice is 11. What is the probability the player will win?
In a casino game, the player rolls a pair of dice. If the first throw is a 7 or an 11, the player wins automatically. What is the probability that the player will win on the first throw? 30A. 30B. In 1999, the stock market took big swings up and down. A survey of 997 investors asked how often they tracked their portfolio. The table shows the investor responses. What is the probability that an investor tracked their portfolio daily...
The Game is called Twenty-One. The user rolls dice in an attempt to hit exactly 21. If the user goes over 21, they lose. If they hit 21 exactly, they win. Pop upa message box that informs the user if they win or lose. Then they can play the game again if they want. At first the user should roll 2 dice. Once their total hits 15 or above, they should only roll one dice. (Use a random...
1 point) Three brothers play a game with a pair of fair (six-sided) dice. Scott will win if the sum of the dice is 3, Dave will win if 9, and Jim if 11 They will roll the die until a winner is declared Part (c) Realizing this, theoretically, is a game that could go on forever..the three brothers decide that if no winner has been decided in three rolls or "turns" Scott will be deemed the winner. Let Y...
Bob and Doug are playing the following game. Bob starts by rolling two fair dice; if the sum of his dice is six, then he wins the game. If not, then Doug rolls the dice, and if the sum of his rolls is seven, then he wins the game. If neither player wins the game during the first round, then they repeat the process (with Bob going first) until someone wins a round. What is the probability that Bob wins...
Two player Dice game In C++ The game of ancient game of horse, not the basketball version, is a two player game in which the first player to reach a score of 100 wins. Players take alternating turns. On each player’s turn he/she rolls a six-sided dice. After each roll: a. If the player rolls a 3-6 then he/she can either Roll again or Hold. If the player holds then the player gets all of the points summed up during...
Bob plays a game in which he rolls a pair of fair 6-sided dice once. He adds the number of dots on both dice to create a sum. He loses $1 if he rolls a sum less than 5 doesn’t win or lose anything if he rolls a sum that is higher than 4, but less than 8 wins $1 if he rolls a sum that’s higher than 7 but less than 12 wins $2 if he rolls a sum...