In Python. Write a program to calculate the score from a throw of five dice. Step 0. Review the provided main code. 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 1. Complete the check_singles() function. Return the sum of all values that match parameter goal. Update the find_high_score() function to use a loop to call check_singles() six times with parameters being 1 - 6. Return the highest score from all function calls. Ex: If input is: 2 4 1 5 4 the output is: High score: 8 Step 2. 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. Ex: If input is: 2 4 4 5 4 the output is: High score: 30 Step 3. 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. Step 4. 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). Update the find_high_score() function to call check_straight() and return the highest score from all function calls.
In Python. Write a program to calculate the score from a throw of five dice.
Step 0. Review the provided main code. 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 1. Complete the check_singles() function. Return the sum of all values that match parameter goal. Update the find_high_score() function to use a loop to call check_singles() six times with parameters being 1 - 6. Return the highest score from all function calls.
Ex: If input is:
2 4 1 5 4
the output is:
High score: 8
Step 2. 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.
Ex: If input is:
2 4 4 5 4
the output is:
High score: 30
Step 3. 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.
Step 4. 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). Update the find_high_score() function to call check_straight() and return the highest score from all function calls.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images