lab 9 numpy arrays

Background

  • In a modified game of Yahtzee, five eight-sided dice are rolled once.
  • For this assignment, you will simulate this modified game of Yahtzee to determine how likely certain outcomes are.
  • In this modified version of Yahtzee, a Low Roll occurs when each of the five dice is either a 1 or an 2. For example, 1-1-1-1-1 or 2-2-1-2-1.
  • In this modified version of Yahtzee, a Three of a Kind occurs when three of the dice show the same number. The other two dice must not show this number and must also be different from one another. For example, 4-7-4-4-2 but not 4-7-4-4-7.
  • In this modified version of Yahtzee, a large straight occurs when the five numbers can be arranged consecutively (for example, 1-3-4-2-5 or 5-7-4-6-3). Hint: the numpy library contains a sort function.

Assignment

  • Download lab9.py (below) rename it according to the instructions above, and make sure you understand it.
  • Take the program above and modify it by adding the missing methods such that when the program is run, it might produce the output below. Do not change any of the existing Python code (except to learn it — if you do, change it back).

Grading – 10 points

  • 3 points – Low Rolls are identified correctly.
  • 3 points – Three of a Kinds are identified correctly.
  • 4 points – Large straights are identified correctly.

Sample Transcripts

Below are a few runs of the program. Notice it can vary a bit from run to run, but with a sample size as large as 20,000, it tends to be fairly close…

>>> 
= RESTART: /Users/danieldefrance/Google Drive/CSCI/Courses/04_2020S/127/Assignments/lab09/Daniel-DeFrance-Lab09.py
Number of Rolls: 20000
---------------------
Number of Low Rolls: 15
Percent: 0.07%

Number of Three of a Kinds: 2384
Percent: 11.92%

Number of Large Straights: 331
Percent: 1.66%

>>>
= RESTART: /Users/danieldefrance/Google Drive/CSCI/Courses/04_2020S/127/Assignments/lab09/Daniel-DeFrance-Lab09.py
Number of Rolls: 20000
---------------------
Number of Low Rolls: 17
Percent: 0.09%

Number of Three of a Kinds: 2404
Percent: 12.02%

Number of Large Straights: 316
Percent: 1.58%

>>>
= RESTART: /Users/danieldefrance/Google Drive/CSCI/Courses/04_2020S/127/Assignments/lab09/Daniel-DeFrance-Lab09.py
Number of Rolls: 20000
---------------------
Number of Low Rolls: 17
Percent: 0.09%

Number of Three of a Kinds: 2374
Percent: 11.87%

Number of Large Straights: 286_x000D_ _x000D_ Percent: 1.43%

"Is this question part of your assignment? We can help"

ORDER NOW