Answered step by step
Verified Expert Solution
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 rolldice function in hog.py It takes two arguments: a positive integer called numrolls 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 Sow Sad Sow Sad. If any of the dice outcomes is a the current player's score for the turn is To obtain a single outcome of a dice roll, call dice You should call dice exactly numrolls times in the body of rolldice. Remember to call dice exactly numrolls 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 rolldice function, and many other functions throughout the project, makes use of default argument valuesyou can see this in the function heading: def rolldicenumrolls, dicesixsided: The argument dicesixsided means that when rolldice is called, the dice argument is optional. If no value for dice is provided, then sixsided is used by default. For example, calling rolldice foursided or equivalently rolldice dicefoursided simulates rolling foursided dice, while calling rolldice simulates rolling sixsided dice. Understand the problem: Before writing any code, unlock the tests to verify your understanding of the question: python ok q 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: python ok q
Implement the rolldice function in hog.py It takes two arguments: a positive integer called numrolls 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 Sow Sad
Sow Sad. If any of the dice outcomes is a the current player's score for the turn is
To obtain a single outcome of a dice roll, call dice You should call dice exactly numrolls times in the body of rolldice.
Remember to call dice exactly numrolls 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 rolldice function, and many other functions throughout the project, makes use of default argument valuesyou can see this in the function heading:
def rolldicenumrolls, dicesixsided:
The argument dicesixsided means that when rolldice is called, the dice argument is optional. If no value for dice is provided, then sixsided is used by default.
For example, calling rolldice foursided or equivalently rolldice dicefoursided simulates rolling foursided dice, while calling rolldice simulates rolling sixsided dice.
Understand the problem:
Before writing any code, unlock the tests to verify your understanding of the question:
python ok q 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:
python ok q
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started