IN PYTHON
Implement function yahtzee() that rolls (5) die
(numbered 0 through 4) three times and prints the result after each
roll. After each roll of the dice, the player is asked whether she
wants to save one, or more, of the dice rolls. Here is an example
usage:
>>> yahtzee()
You have 6, 3, 3, 5, and 4
What dice do you want to save? 1,2
You have 5, 3, 3, 1, and 6
What dice do you want to save? 1,2
You have 3, 3, 3, 3, and 5
Write your score.
The result of the first roll for the five dice is 6, 3, 3, 5,
and 4. The player chooses to save the result for dice 1 and 2 (the
two 3s). During the second roll only the "unsaved" dice will be
rolled, i.e. dice 0, 3, and 4. After that roll, the player decides
to again save the two 3s. After the third roll, involving only dice
0, 3, and 4, the final value of the dice is obtained. Here are a
few more examples:
>>> yahtzee()
You have 2, 1, 4, 6, and 2
What dice do you want to save? 0,4
You have 2, 5, 4, 6, and 2
What dice do you want to save? 1,2,3
You have 2, 5, 4, 6, and 1
Write your score.
>>> yahtzee()
You have 5, 4, 1, 6, and 3
What dice do you want to save? 0,1,3,4
You have 5, 4, 3, 6, and 3
What dice do you want to save? 0,1,2,3
You have 5, 4, 3, 6, and 4
Write your score.
Code
import random as rand
def yahtzee():
saveddice = {}
rolleddice = []
for a in range(3):
rolleddice = []
for b in range(5):
rolleddice.append(rand.randint(1, 6))
for c in saveddice:
rolleddice[c] = saveddice[c]
print('You have ' + str(rolleddice[0]) + ', ' + str(rolleddice[1])
+ ', ' + str(rolleddice[2]) + ', ' + str(
rolleddice[3]) + ', and ' + str(rolleddice[4]))
if a != 2:
s = input('What dice do you want to save? ')
saveddice = {}
l = [int(a) for a in s.split(',')]
for n in l:
saveddice[n] = rolleddice[n]
print('Write your score.')
if __name__ == '__main__':
yahtzee()
Screenshot

Output

--
i used onlinegdb ide for compiling and executing the code
all the best
IN PYTHON Implement function yahtzee() that rolls (5) die (numbered 0 through 4) three times and...
In Yahtzee, 5 standard dice are rolled up to three times on a given turn. A player can choose to save anywhere from 0 - 5 of the dice between rolls 1 and 2 and between rolls 2 and 3, meaning that the player can set aside certain dice before rolling the remaining dice if they choose to do so. Suppose that a given player does not take advantage of saving die rolls and instead rolls all 5 dice each...
Write a Python (version 3.5.2) program that simulates how often certain hands appear in Yahtzee. In Yahtzee, you roll five dice and then use those dice to make certain combinations. For example, the Yahtzee combination is formed by all five dice having the same value. A large straight occurs when all of the dice are in consecutive order (e.g., 1,2,3,4,5 or 2,3,4,5,6). If you haven’t played Yahtzee, you can find out more from various online sources such as Wikipedia. Once...
I need java code for this . The assignment requires using
objects
Exercise 2 of 2: Create a program that lets the player play a simplified game of Yahtzee. The game starts with the user throwing five 6-sided dice. The user can choose which dice to keep and which dice to re-roll. The user can re-roll a maximum of 2 times. After two times, the user has 5 dice with a certain value. The player then has to choose where...
Develop a C++ program which will play a simplified version of the dice game Yahtzee For simplicity, this version of the game only uses four dice No prompting of the user for input values is required Simply use four variables called A, B, C, D to maintain dice roll values int A = 2; No input validation is required as well From the input you will determine if the player rolled 4 of a kind, 3 of a kind, 2...
Write a class called OneRoundOneRollYahtzee. The program should behave the same as the InputOrGenerateDiceRolls (which is as follows: InputOrGenerateDiceRolls program should ask the user whether the user prefers 1) to roll his/her own dice, 2) use computer-generated dice rolls, or 3) quit the program. If the user prefers to roll his/her own dice, the program should prompt the user to enter 5 digits in the range from 1-6 separated by spaces in any order with duplicates allowed. However, if the...
Complete each problem separately and perform in python. 1. Create a script that will roll five dice and print out their values. Allow the user to roll the dice three times. Prompt them to hit enter to roll. Ex: Hit enter to roll 1,4,3,6,6 Hit enter to roll 3,5,1,2,1 Hit enter to roll 4,3,4,2,6 2. Write a script that will roll five dice (just one time). The user's score will be the sum of the values on the dice. Print...
d. After 18 rolls, what would be the empirical probability of getting a three on at least one of those rolls? Also, list the likelihood scale term from the table above. Percent Probability Empirical Probability (Rounded to the Nearest Whole Percent) (2 points) ? Likelihood Scale Term (2 points) ? Show your work: What do you notice about the answers for parts c and d above? (2 points) ? Roll the dice 18 times and keep track of what is...
Two strange dice (Die A and Die B) are rolled and their numbers showing are to be added together. Die A and one side that is a 1, while the other sides are 3’s. Die B has four sides that are 2’s and two sides that are 6’s. Complete this table showing the sample space for this event. + 1 3 3 3 3 3 2 2 2 2 6 6 P(sum of 5) = Using the same strange dice...
Create a Dice Game: PYTHON This game is between two people. They will roll a pair of dice each 10 times. Each roll will be added to a total, and after 10 rolls the player with the highest total will be the Winner! You will use the RANDOM class RANDRANGE to create a random number from 1 to 6. You'll need a function for "rollDice" to roll a pair of dice and return a total of the dice. You must...
The Dice game of "Pig" can be played with the following rules. 1. Roll two six-sided dice. Add the face values together. 2. Choose whether to roll the dice again or pass the dice to your opponent. 3. If you pass, then you get to bank any points earned on your turn. Those points become permanent. If you roll again, then add your result to your previous score, but you run the risk of losing all points earned since your...