Question: pls use python do this Problem 6A. Computer word choose First we must create a function that allows the computer to choose a word. We

pls use python do this
Problem 6A. Computer word choose
First we must create a function that allows the computer to choose a word.
We have provided the function get_perms(hand, n) (defined in perm.py, but usable by simply calling get_perms(hand, n)). The specification is as follows:
def get_perms(hand, n):
"""Takes in the current hand and a number which
must be less than or equal to the size of the hand. It returns all
possible permutations of size n given the letters in the hand.
hand: dictionary (string -> int)
n: int bounded by 0 < n >= len(hand)
returns list (string)
"""
#IMPLEMENTED...
You are not required to know how get_perms works.
It is your responsibility to create the function comp_choose_word(hand, word_list)
def comp_choose_word(hand, word_list):
"""
Given a hand and a word_dict, find the word that gives the maximum value score, and return it.
This word should be calculated by considering all possible permutations of lengths 1 to HAND_SIZE.
hand: dictionary (string -> int)
word_list: list (string)
"""
# TO DO...
Hint: First try to make a legal player, and then worry about making the computer player better (if you have time).
Problem 6B. Computer's turn to play a hand
Now you need to write a function similar to Part As play_hand.
Implement the comp_play_hand function. This function should allow the computer to play the game through completion.
def comp_play_hand(hand, word_list):
"""
Allows the computer to play the given hand, as follows:
* The hand is displayed.
* The computer chooses a word using comp_choose_words(hand, word_dict).
* After every valid word: the score for that word is displayed,
the remaining letters in the hand are displayed, and the computer
chooses another word.
* The sum of the word scores is displayed when the hand finishes.
* The hand finishes when the computer has exhausted its possible choices (i.e. comp_play_hand returns None).
hand: dictionary (string -> int)
word_list: list (string)
"""
# TO DO ...
Problem 6C. You and your computer
Now that your computer can choose a word, you need to give the computer the option to play.
Write the code that re-implements the play_game function. You will modify the function to behave as described below in the functions comments.
As before, you should use the HAND_SIZE constant to determine the number of cards in a hand. If you like, you can try out different values for HAND_SIZE with your program.
def play_game(word_list):
"""Allow the user to play an arbitrary number of hands.
1) Asks the user to input 'n' or 'r' or 'e'.
* If the user inputs 'n', play a new (random) hand.
* If the user inputs 'r', play the last hand again.
* If the user inputs 'e', exit the game.
* If the user inputs anything else, ask them again.
2) Ask the user to input a 'u' or a 'c'.
* If the user inputs 'u', let the user play the game as before using play_hand.
* If the user inputs 'c', let the computer play the game using comp_play_hand (created above).
* If the user inputs anything else, ask them again.
3) After the computer or user has played the hand, repeat from step 1
word_list: list (string)
"""
# TO DO...

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 Databases Questions!