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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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. 

# Check for full house (score = 35)
def
check_full_house(dice):
score 0
#Type your code here.
return score
# Check for straight (score= 45)
def check_straight (dice):
score 0
#Type your code here.
return score
if ___name__ == '__main__': #Do not modify
#Fill array with five dice from input
dice [int(val) for val in input().split()]
high_score= 0
#Place dice in ascending order
dice. sort()
#Find high score and output
high score find_high_score(dice)
print(f'High score: { high_score }')
Transcribed Image Text:# Check for full house (score = 35) def check_full_house(dice): score 0 #Type your code here. return score # Check for straight (score= 45) def check_straight (dice): score 0 #Type your code here. return score if ___name__ == '__main__': #Do not modify #Fill array with five dice from input dice [int(val) for val in input().split()] high_score= 0 #Place dice in ascending order dice. sort() #Find high score and output high score find_high_score(dice) print(f'High score: { high_score }')
#Find highest score
def find_high_score (values):
high_score= 0
#Type your code here.
return high score
# Add all occurences of goal value
def check_singles(dice, goal):
score = 0
# Type your code here.
return score
# Check for three of a kind (score 30)
def check_three_of_kind(dice):
score 0
# Type your code here.
return score
# Check for four of a kind (score
def check_four_of_kind(dice):
score 0
# Type your code here.
return score
-
return score
40)
# Check for five of a kind (score 50)
def check_five_of_kind(dice):
score = 0
# Type your code here.
Transcribed Image Text:#Find highest score def find_high_score (values): high_score= 0 #Type your code here. return high score # Add all occurences of goal value def check_singles(dice, goal): score = 0 # Type your code here. return score # Check for three of a kind (score 30) def check_three_of_kind(dice): score 0 # Type your code here. return score # Check for four of a kind (score def check_four_of_kind(dice): score 0 # Type your code here. return score - return score 40) # Check for five of a kind (score 50) def check_five_of_kind(dice): score = 0 # Type your code here.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Lists
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education