Question: pls use python do this Problem 1. Word scores The first step is to implement some code that allows us to calculate the score for

pls use python do this

Problem 1. Word scores

The first step is to implement some code that allows us to calculate the score for a single word.

The function get_word_score should accept a string of lowercase letters as input (a word) and return the integer score for that word, using the games scoring rules.

Fill in the code for get_word_score in ps3a.py:

def get_word_score(word, n):
"""
Returns the score for a word. Assumes the word is a
valid word.

The score for a word is the sum of the points for letters
in the word multiplied by the length of the word, plus 50
points if all n letters are used on the first go.

Letters are scored as in Scrabble; A is worth 1, B is
worth 3, C is worth 3, D is worth 2, E is worth 1, and so on.

word: string (lowercase letters)
returns: int >= 0
"""
# TO DO...

You may assume that the input word is always either a string of lowercase letters, or the empty string "". You will want to use the SCRABBLE_LETTER_VALUES dictionary defined at the top of ps3a.py. You should not change its value.

Do not assume that there are always 7 letters in a hand! The parameter n is the number of letters required for a bonus score (the maximum number of letters in the hand).

Testing: If this function is implemented properly, and you run test_ps3a.py, you should see that the test_get_word_score()tests pass. Also test your implementation of get_word_score, using some reasonable English words.

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!