Question: Complete the get_word_score() function that takes a single string parameter word. The function returns an integer score that is based on the length of the

Complete the get_word_score() function that takes a single string parameter word. The function returns an integer score that is based on the length of the word plus some bonuses and less some penalties. The rules governing the score are as follows:

  • The base score is given by the length of the word.
  • If the word contains the letter "e" (uppercase or lowercase) subtract a penalty of 1.
  • If the word contains the letter "s" (uppercase or lowercase) subtract a penalty of 1.
  • If the word contains the letter "z" (uppercase or lowercase) add a bonus of 2.
  • If the word contains the letter "q" (uppercase or lowercase) add a bonus of 3.

Some examples of the function being called are shown below.

For example:

Test Result
word = "SnakeS" score = get_word_score(word) print("Your word score is", score)
Your word score is 4
print("Your word score is", get_word_score("Quiz"))
Your word score is 9
print("Your word score is", get_word_score("ZoOm"))
Your word score is 6

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!