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 user-defined 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 1
Review the provided main code (diceGame.py) on D2L. 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 find_high_score() to determine the highest scoring category. Make no changes to the main code. Stubs are provided for all remaining functions.
Step 2
Complete the check_singles() function. Return the largest number in the list without using a built-in min/max function. Update the find_high_score() function to call check_singles()and 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:
24154
the output is:
High score: 5
Step 3
Complete the check_three_of_kind(), check_four_of_kind(), and check_five_of_kind() functions.
(Hint: Since the values are in ascending order, same values are stored in consecutive index locations.)
Return 30 from check_three_of_kind() if the dice contain at least three of the same values.
Ex: (2,3,3,3,6).
Return 40 from check_four_of_kind() if the dice contain at least four of the same values.
Ex: (4,4,4,4,5).
Return 50 from check_five_of_kind() if the dice contain five identical values.
Ex: (5,5,5,5,5).
Update the find_high_score() 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:
24454
the output is:
High score: 30
Step 4
Complete the check_full_house() function to return 35 if the dice contain a full house (a pair and three of a kind). Ex: (1,1,3,3,3).
Note: Five of a kind also satisfies the definition of a full house since (4,4,4,4,4) includes a pair of 4s and three 4s. Update the find_high_score() function to call check_full_house() and return the highest score from all function calls. Run test cases in your development environment accordingly.
Step 5
Complete the check_straight() function to return 45 if the dice contain a straight of (1,2,3,4,5) or (2,3,4,5,6). Up

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!