Menu

(Solved) : Game Lucky Sevens Player Rolls Pair Dice Dots Add 7 Player Wins 4 Otherwise Player Loses 1 Q35962401 . . .

In the game of Lucky Sevens, theplayer rolls a pair of dice. If the dots add up to 7, the playerwins $4; otherwise, the player loses $1. Suppose that, to enticethe gullible, a casino tells players that there are many ways towin: (1, 6), (2, 5), and soon. A little mathematical analysisreveals that there are not enough ways to win to make the gameworthwhile; however, because many people’s eyes glaze over at thefirst mention of mathematics “wins $4”.

Your challenge is to write a programthat demonstrates the futility of playing the game. Your Pythonprogram should take as input the amount of money that the playerwants to put into the pot, and play the game untilthe pot is empty.

The program should have atleast TWO functions (Input validation andSum of the dots of user’s two dice). Like the program 1, your codeshould be user-friendly and able to handle all possible user input.The game should be able to allow a user to ply several times.

Using Python, how can I ask the user to play the gameagain and allow them too? With the following code provided. Thankyou

name = input(“Hi, welcome to the game of Lucky Seven! What’syour name?”)

print(“Welcome”,name,”How much money would you like to put in?(Use whole integer i.e. 5 or 10)”)

def sumDots():

    first = random.randint(1,6) #Produces arandom number for first dice

    second = random.randint(1,6) #Produces arandom number for second dice

    return first+second #Returns the totalroll

def getinput(): #Getting the input from the user

    while True:

        amount = input(“Howmuch money would you like to put in?:”) #Taking input

        try:

           amm = int(amount) #Converts it to a integer

           if(amm<=0):

               print(“Invalid number, greater than zero please”) #Letting userknow that they cannot use any negative number or 0

               continue

           return amm

        except valueError:#if not given an integer as input, repeat samething

           print (“Invalid number, greater than zero please”)

           continue

initial = getinput() #Gets input

total = initial #The initial pot value to a total value

rolls = 0

maxi = initial;

print(“Number of Rollstttt Win or Loss tttt CurrentValue of the Pot”) #This is the model

while(total > 0):

    dices = sumDots() #roll the two dices

    rolls +=1 #Counts the number of rolls

    result = “” #Win or Loss

    if dices == 7: #Winning will add $4

        total = total + 4

        result = “Win”

    else: #If loss we will reduce $1

        total = total – 1

        result = “Loss”

    if(maxi < total):

        maxi = total;

   print(rolls,”ttttt”,result,”ttttt”,total) #Printresults

print(“nnThe maximum amount in pot was $”,maxi);

Expert Answer


Answer to Game Lucky Sevens Player Rolls Pair Dice Dots Add 7 Player Wins 4 Otherwise Player Loses 1 Q35962401 . . .

OR