Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the roll _ dice function in hog.py . It takes two arguments: a positive integer called num _ rolls giving the number of times

Implement the roll_dice function in hog.py. It takes two arguments: a positive integer called num_rolls giving the number of times to roll a die and a dice function. It returns the number of points scored by rolling the die that number of times in a turn: either the sum of the outcomes or 1(Sow Sad).
Sow Sad. If any of the dice outcomes is a 1, the current player's score for the turn is 1.
To obtain a single outcome of a dice roll, call dice(). You should call dice() exactly num_rolls times in the body of roll_dice.
Remember to call dice() exactly num_rolls times even if Sow Sad happens in the middle of rolling. By doing so, you will correctly simulate rolling all the dice together (and the user interface will work correctly).
Note: The roll_dice function, and many other functions throughout the project, makes use of default argument valuesyou can see this in the function heading:
def roll_dice(num_rolls, dice=six_sided): ...
The argument dice=six_sided means that when roll_dice is called, the dice argument is optional. If no value for dice is provided, then six_sided is used by default.
For example, calling roll_dice(3, four_sided), or equivalently roll_dice(3, dice=four_sided), simulates rolling 3 four-sided dice, while calling roll_dice(3) simulates rolling 3 six-sided dice.
Understand the problem:
Before writing any code, unlock the tests to verify your understanding of the question:
python3 ok -q 01-u
Note: You will not be able to test your code using ok until you unlock the test cases for the corresponding question.
Write code and check your work:
Once you are done unlocking, begin implementing your solution. You can check your correctness with:
python3 ok -q 01

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

Students also viewed these Databases questions

Question

Explain the importance of Human Resource Management

Answered: 1 week ago

Question

Discuss the scope of Human Resource Management

Answered: 1 week ago

Question

Discuss the different types of leadership

Answered: 1 week ago

Question

Write a note on Organisation manuals

Answered: 1 week ago

Question

Define Scientific Management

Answered: 1 week ago