Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

Students also viewed these Databases questions

Question

Prepare an ID card of the continent Antarctica?

Answered: 1 week ago

Question

What do you understand by Mendeleev's periodic table

Answered: 1 week ago

Question

6. Is all Internet training the same? Explain.

Answered: 1 week ago