Question

Use PYTHON!!! NOT Java or anything else!! Function name : crazy_scrabble Parameters : word (string), current...

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 player’s 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

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def crazy_scrabble(word, current_points, double_word_score):
    points = 0
    for i in range(len(word)):
        ch = word[i]
        if ch in "kmpxyz":
            points += 7
        elif ch in "cs":
            points += 4
        elif ch in "aeiou":
            points -= 2
        else:
            points += 1

        if ch in word[:i]:
            points -= 1
    if len(word) > 6:
        points += 3

    if double_word_score and points > 0:
        points *= 2

    points += current_points
    if points < 0:
        points = 0

    return points


print(crazy_scrabble('xylophone', 25, False))
print(crazy_scrabble('seal', 0, True))
print(crazy_scrabble('oranges', 7, True))

Add a comment
Know the answer?
Add Answer to:
Use PYTHON!!! NOT Java or anything else!! Function name : crazy_scrabble Parameters : word (string), current...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Function name: crazy_scrabble Parameters : word (string), current points (int), double word score (boolean) Returns: int...

    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'...

  • Python String Product Function Name: string Multiply Parameters: sentence (str), num (int) Returns: product (int) Description:...

    Python String Product Function Name: string Multiply Parameters: sentence (str), num (int) Returns: product (int) Description: You're texting your friend when you notice that they replace many letters with numbers. Out of curiosity, you want to find the product of the numbers. Write a function that takes in a string sentence and an int num, and find the product of only the first num numbers in the sentence. If num is 0, return 0. If num > O but there...

  • Methods: Net beans IDE Java two methods. Identifier: calculateScore(String word) Parameters: word – the word for...

    Methods: Net beans IDE Java two methods. Identifier: calculateScore(String word) Parameters: word – the word for which you should calculate the points in Scrabble Return Value: int – the number of points for the parameter word Other: This method should be static. This method should use the following system for scoring: 0 – blank 1 – e, a, i, o, n, r, t, l, s, u 2 – d, g 3 – b, c, m, p 4 – f, h,...

  • Question 2: Finding the best Scrabble word with Recursion using java Scrabble is a game in...

    Question 2: Finding the best Scrabble word with Recursion using java Scrabble is a game in which players construct words from random letters, building on words already played. Each letter has an associated point value and the aim is to collect more points than your opponent. Please see https: //en.wikipedia.org/wiki/Scrabble for an overview if you are unfamiliar with the game. You will write a program that allows a user to enter 7 letters (representing the letter tiles they hold), plus...

  • You will write a two-class Java program that implements the Game of 21. This is a...

    You will write a two-class Java program that implements the Game of 21. This is a fairly simple game where a player plays against a “dealer”. The player will receive two and optionally three numbers. Each number is randomly generated in the range 1 to 11 inclusive (in notation: [1,11]). The player’s score is the sum of these numbers. The dealer will receive two random numbers, also in [1,11]. The player wins if its score is greater than the dealer’s...

  • Create a Java text-based simulation that plays baccarat between two players. In baccarat, there i...

    Create a Java text-based simulation that plays baccarat between two players. In baccarat, there is a banker and there is a player. Two cards are dealt to the banker and two cards to the player. Both cards in each hand are added together, and the objective (player) is to draw a two or three-card hand that totals closer to 9 than the banker. In baccarat, the card values are as follows: • 2–9 are worth face value • 10, J,...

  • Python The Python "<" and ">" comparison operators can be used to compare which string variable...

    Python The Python "<" and ">" comparison operators can be used to compare which string variable has a greater value based on comparing the ASCII codes of the characters in each string, one by one. To take some examples: "tets" > "test" returns True because the third letter of the first string, "t", has a greater value than the third letter of the second string, "s". "testa" > "test" returns True because—while the first four letters in both words are...

  • I am trying to make a word guessing game on java, where there are four letters...

    I am trying to make a word guessing game on java, where there are four letters and you have 10 guesses to try and guess the letter combination. When I try to play, it says every combination of letters I enter is correct. For example: "You have 10 guesses left. Enter your guess: wxyz There are 4 correct letter placements. Congrats!" I emailed my professor and she said one of my methods is wrong because I'm only checking for specific...

  • Two player Dice game In C++ The game of ancient game of horse, not the basketball...

    Two player Dice game In C++ The game of ancient game of horse, not the basketball version, is a two player game in which the first player to reach a score of 100 wins. Players take alternating turns. On each player’s turn he/she rolls a six-sided dice. After each roll: a. If the player rolls a 3-6 then he/she can either Roll again or Hold. If the player holds then the player gets all of the points summed up during...

  • Write a class called Player that has four data members: a string for the player's name,...

    Write a class called Player that has four data members: a string for the player's name, and an int for each of these stats: points, rebounds and assists. The class should have a default constructor that initializes the name to the empty string ("") and initializes each of the stats to -1. It should also have a constructor that takes four parameters and uses them to initialize the data members. It should have get methods for each data member. It...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT