Question

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 u
Programming Exercise 3.11 Instructions sevens.py 1 # Put your code here > Your program should take as input the amount of mon
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code

import random
def getSumOfPairedDice():
return (random.randint(0,6)+random.randint(0,6))


def main():
ammount=int(input("How many dollars do you have?"))
maxAmount=ammount
maxRolls=0
numOfRolls=0
while ammount>0:
numOfRolls+=1
dice=getSumOfPairedDice()
if(dice==7):
ammount+=4
else:
ammount-=1
if(maxAmount<ammount):
maxAmount=ammount
maxRolls=numOfRolls
print("You are broke after ",numOfRolls," rolls.")
print("You shoud have quit after ",maxRolls," rolls when you had ",maxAmount)

if __name__ == '__main__':
main()

output

code

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.

Add a comment
Know the answer?
Add Answer to:
Instructions sevens.py 1 # Put your code here In the game of Lucky Sevens, the player...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The game of Pig is a simple two-player dice game in which the first player to...

    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...

  • C# Code: Write the code that simulates the gambling game of craps. To play the game,...

    C# Code: Write the code that simulates the gambling game of craps. To play the game, a player rolls a pair of dice (2 die). After the dice come to rest, the sum of the faces of the 2 die is calculated. If the sum is 7 or 11 on the first throw, the player wins and the game is over. If the sum is 2, 3, or 12 on the first throw, the player loses and the game is...

  • Please i need helpe with this JAVA code. Write a Java program simulates the dice game...

    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...

  • Two player Dice game In C++ The game of ancient game of horse, not the basketball...

    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...

  • Can someone upload a picture of the code in matlab Write a "Guess My Number Game"...

    Can someone upload a picture of the code in matlab Write a "Guess My Number Game" program. The program generates a random integer in a specified range, and the user (the player) has to guess the number. The program allows the use to play as many times as he/she would like; at the conclusion of each game, the program asks whether the player wants to play again The basic algorithm is: 1. The program starts by printing instructions on the...

  • the card game Acey Deucey, which is also known by several other names. In general, the...

    the card game Acey Deucey, which is also known by several other names. In general, the game is played with three or more people that continue to gamble for a pot of money. The pot grows and shrinks depending on how much General description of the game ● Two cards are dealt face up to a player from a shuffled deck of cards. ○ If the face of each card is the same then the player adds $1 into the...

  • Using C++ Create a Blackjack program with the following features: Single player game against the dealer....

    Using C++ Create a Blackjack program with the following features: Single player game against the dealer. Numbered cards count as the number they represent (example: 2 of any suit counts as 2) except the Aces which can count as either 1 or 11, at the discretion of the player holding the card. Face cards count as 10. Player starts with $500. Player places bet before being dealt a card in a new game. New game: Deal 2 cards to each...

  • Java Listed below is code to play a guessing game. In the game, two players attempt...

    Java Listed below is code to play a guessing game. In the game, two players attempt to guess a number. Your task is to extend the program with objects that represent either a human player or a computer player. boolean checkForWin (int guess, int answer) { System.out.println("You guessed" + guess +"."); if (answer == guess) { System.out.println( "You're right! You win!") ; return true; } else if (answer < guess) System.out.println ("Your guess is too high.") ; else System.out.println ("Your...

  • You play the following bargaining game. Player A moves first and makes Player B an offer...

    You play the following bargaining game. Player A moves first and makes Player B an offer for the division of ​$1000. ​ (For example, Player A could suggest that she take ​$600 and Player B take ​$400​.) Player B can accept or reject the offer. If he rejects​ it, the amount of money available drops to ​$900​, and he then makes an offer for the division of this amount. If Player A rejects this​ offer, the amount of money drops...

  • 1 point) Three brothers play a game with a pair of fair (six-sided) dice. Scott will...

    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...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT