Question
I want to know how to make these lines to work In the game of Lucky Sevens, the player rolls a pair of dice. If
I want to know how to make these lines to work
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), etc. A little mathematical analysis reveals that there are not enough ways to win to make the game worthwhile; however, because many peoples eyes glaze over at the first mention of mathematics, your challenge is to write a program that demonstrates the futility of playing the game.
Your 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. At that point, the program should print the number of rolls it took to break the player, as well as maximum amount of money in the pot.
import random
# Request the input
dollars = int(input("How many dollars do you have? "))
# Initialize variables
maxDollars = dollars
countAtMax = 0
count = 0
# Loop until the money is gone
while
# Roll the dice
die1 = random.randint(1, 6) # 1-6
die2 = random.randint(1, 6) # 1-6
#Calculate the winnings or losses
if
else:
#If this is a new maximum, remember it
if
# Display the results
print("You are broke after " + str(count) + " rolls. " + \
"You should have quit after " + str(countAtMax) + \
" rolls when you had $" + str(maxDollars) + ".")
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started