Question: Write a Python program to calculate the score from a throw of five dice using user - defined functions. Scores are assigned to different categories
Write a Python program to calculate the score from a throw of five dice using userdefined functions. Scores are assigned to different categories for singles three of a kind, four of a kind, five of a kind, full house, and straight.
NOTE: This project does NOT require a project plan. Follow each step to gradually complete all functions. This emphasizes incremental development.
Step
Review the provided main code diceGamepy on DL Remember to change the filename according to specifications detailed at the end of this document. In this file, five integer values are input and inserted into a list. The list is sorted and passed to findhighscore to determine the highest scoring category. Make no changes to the main code. Stubs are provided for all remaining functions.
Step
Complete the checksingles function. Return the largest number in the list without using a builtin minmax function. Update the findhighscore function to call checksinglesand adjust the score. Return the highest score from all function calls. In your development environment, make sure test cases will pass by running the code with the following data:
If input is:
the output is:
High score:
Step
Complete the checkthreeofkind checkfourofkind and checkfiveofkind functions.
Hint: Since the values are in ascending order, same values are stored in consecutive index locations.
Return from checkthreeofkind if the dice contain at least three of the same values.
Ex:
Return from checkfourofkind if the dice contain at least four of the same values.
Ex:
Return from checkfiveofkind if the dice contain five identical values.
Ex:
Update the findhighscore function to call the three functions and return the highest score from all function calls. In your development environment, make sure two test cases pass by running the code with the following data:
If input is:
the output is:
High score:
Step
Complete the checkfullhouse function to return if the dice contain a full house a pair and three of a kind Ex:
Note: Five of a kind also satisfies the definition of a full house since includes a pair of s and three s Update the findhighscore function to call checkfullhouse and return the highest score from all function calls. Run test cases in your development environment accordingly.
Step
Complete the checkstraight function to return if the dice contain a straight of or Up
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
