Answered step by step
Verified Expert Solution
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started