Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The dice are rolled, and the game begins. Yahtzee! (haiku written for CMPUT 174 by GPT-3) Have you ever played Yahtzee? It's a board game

image text in transcribed
image text in transcribed
image text in transcribed
The dice are rolled, and the game begins. Yahtzee! (haiku written for CMPUT 174 by GPT-3) Have you ever played Yahtzee? It's a board game that is played by two players. The players take turns rolling five dice, and the player with the highest score wins. Now might be a good time to review the game rules: Yahtzee Game Rules. In the first version, you will implement user-defined functions for the Upper Section of Yahtzee. What to do Create a new file called yahtzee1.py. Implement the main() function and following user-defined functions: - make_roli() - sum_of_given_number() - fili_upper_section() - display_upper_section() Example Your main() function will do the following: 1. Roll the dice by calling the make_ro11() function and display the random roll. For this example, let's assume that the random roll is (2,1,5,1,5). The following message will be displayed: Rolling the dice... ( 2,1,5,1,5) 2. Fill the upper section of Yahtzee by calling the fill_upper_section() function that calculates sums of each number. In our example, the list returned by this function will look like this: [2,2,,,10,] It means that the sum of all ones is 2 (there are two ones), the sum of all twos is 2 (there is a single two), the sum of all threes is 0 (there are no threes), etc. The fill_upper_section() function will call the sum_of_given_number() function multiple times. Unlike real Yahtzee, in our simplified version, the player rolls only once to fill out the entire upper section. 3. Display the upper section as follows by calling the display_upper_section() function: Aces: 2 Twos: 2 Threes: Fours: Fives: 10 Sixes: Use the following template. All functions defined in the template must be present and implemented in your code (you may not omit functions). You may add extra functions if needed. def make_roll( ) tuple: Returns a tuple of five random values between 1 and 6 . pass def sum_of_given_number (roll: tuple, number: int) int: Returns the sum of the values in the noll that match the given number. nen pass Hints - Do not overthink your code! Each function is only a few lines of code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions