Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use PYTHON !!! NOT Java or anything else!! Function name : crazy_scrabble Parameters : word (string), current points (int), double word score (boolean) Returns: int

Use PYTHON!!! NOT Java or anything else!!

Function name : crazy_scrabble Parameters : word (string), current points (int), double word score (boolean) Returns: int Description : You are playing scrabble with a friend, and you thought you knew how to calculate how many points you have, but your friend suddenly starts making up all these crazy rules. Write a function that helps keep track of how many points you have with these new rules:

  • Each 'k', 'm', 'p', 'x', 'y', and 'z' earns you 7 points.

  • 'c' and 's' are worth 4 points each.

  • Each vowel ('a','e','i','o','u') you causes you to lose 2 points.

  • All other letters are worth 1 point.

  • Each time a letter is reused in a word, the player loses 1 point.

  • If your word is more than 6 letters long, you get a bonus of 3 points.

  • If the double word score is True and the point total for the word is positive ( > 0),

    the player receives double the points for the word.

    The function should return the players new point total. Assume that the words will not be empty strings and will only consist of lowercase letters from a to z.

    Note: A player cannot have an overall negative point total. Return 0 if the point total would be negative after the new word the player has played. For example, if a player currently has 7 points but would lose 9 points from their new word, the player should have 0 points now, not -2 points.

Test Cases:

>>> crazy_scrabble('xylophone', 25, False) 45 
>>> crazy_scrabble('seal', 0, True) 2 
>>> crazy_scrabble('oranges', 7, True) 15 

REMEMBER, PLEASE USE PYTHON ONLY

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

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

Is this investment worthwhile? Why or why not?

Answered: 1 week ago