Question

In: Computer Science

Use this constant dictionary as a global variable: tile_dict = { 'A': 1, 'B': 3, 'C':...

Use this constant dictionary as a global variable:

tile_dict = { 'A': 1, 'B': 3, 'C': 3, 'D': 2, 'E': 1, 'F': 4, 'G': 2, 'H': 4, 'I': 1, 'J': 8, 'K': 5, 'L': 1, 'M': 3, 'N': 1, 'O': 1, 'P': 3, 'Q': 10, 'R': 1, 'S': 1, 'T': 1, 'U': 1, 'V': 4, 'W': 4, 'X': 8, 'Y': 4, 'Z': 10 }

Implement function scrabblePoints(word) that returns the calculated points for the word based on the tile_dict above. The word parameter is a string. This function takes the string and evaluates the points based on each letter in the word (points per letter is set by the global dictionary). P or p is worth the same points. No points calculated for anything that is not A-Z or a-z.

[You may use upper() and isalpha() ONLY and no other method or built-in function]

Examples:

word = “PYTHON”

print(scrabblePoints(word))

returns:

14

word = “hello!!”

print(scrabblePoints(word))

returns:

8

word = “@#$=!!”

print(scrabblePoints(word))

returns:

0

Note: This function relies on scrabblePoints. Function you solved in Question 2.

Implement function declareWinner(player1Word = “skip”, player2Word = “skip”) that returns either “Player 1 Wins!”, “Player 2 Wins!”, “It’s a Tie”, “Player 1 Skipped Round”, “Player 2 Skipped Round”, “Both Players Skipped Round”. The player1Word and player2Word parameters are both type string. Assume input is always valid. This function should call on the function scrabblePoints to earn credit.

[No built-in function or method needed]

Examples:

player1Word = “PYTHON”

player2Word = “Pizza”

     print(declareWinner(player1Word, player2Word))

     returns:           

     Player 2 Wins!

              print(declareWinner(player1Word))

              returns:           

              Player 2 Skipped Round

Please do the second function only. I just needed to add the first function for reference

Solutions

Expert Solution

Screenshot:

Code:

#tile_dict = { 'A': 1, 'B': 3, 'C': 3, 'D': 2, 'E': 1, 'F': 4, 'G': 2, 'H': 4, 'I': 1, 'J': 8, 'K': 5, 'L': 1, 'M': 3, 'N': 1, 'O': 1, 'P': 3, 'Q': 10, 'R': 1, 'S': 1, 'T': 1, 'U': 1, 'V': 4, 'W': 4, 'X': 8, 'Y': 4, 'Z': 10 }

#def scrabblePoint(word):


def declareWinner(player1Word="skip",player2Word="skip"):
    if player1Word=="skip":
        return "Player 1 Skipped Round"
    elif player2Word=="skip":
        return "Player 2 Skipped Round"
    elif scrabblePoint(player1Word)>scrabblePoint(player2Word):
        return "Player 1 Wins!"
    elif scrabblePoint(player2Word)>scrabblePoint(player1Word):
        return "Player 2 Wins!"
    else:
        return "It’s a Tie"

player1Word="PYTHON"
player2Word="Pizza"
print(declareWinner(player1Word,player2Word))
print(declareWinner(player1Word))

Related Solutions

#Python Given a dictionary gradeCounts = { "A": 8, "D": 3, "B": 15, "F": 2, "C":...
#Python Given a dictionary gradeCounts = { "A": 8, "D": 3, "B": 15, "F": 2, "C": 6 } write the Python statement(s) to print: a) all the keys. b) all the values. c) all the key and value pairs. d) all of the key and value pairs in key order. e) the average value. f) a chart similar to the following in which each row contains a key followed by a number of asterisks equal to the key’s data value....
Define the following concepts: (a) constant capital; (b) variable capital; (c) rate of surplus value; (d)...
Define the following concepts: (a) constant capital; (b) variable capital; (c) rate of surplus value; (d) mass of surplus value.
Never declare a C++ global variable in this class. But global constants are ok. unsigned Size1...
Never declare a C++ global variable in this class. But global constants are ok. unsigned Size1 = 100; // never do this at global scope const unsigned Size2 = 120; // this is ok (but probably not very helpful) Don't use the string class and don't use system functions for math (like pow) or strings (like strlen). These functions are meant to be short and simple; if you're writing something long and complicated, look for a simpler solution. void countdown(...
Create two functions that you can use for a dictionary manager: 1. remove_item(dictionary,key): a function that...
Create two functions that you can use for a dictionary manager: 1. remove_item(dictionary,key): a function that removes the item with the supplied key from the dictionary, if it exits. If the input key doesn’t exist in the dictionary, print out a message saying that the new item has not been removed because there is no matching key in the dictionary. Your function should not produce a Python error if the item does not exist; 2. add_new_item(dictionary,key,value): a function that adds...
A and B react as follows: A + B = C + D. The equilibrium constant...
A and B react as follows: A + B = C + D. The equilibrium constant is 2.0 x 10^3. If 0.30 mol of A and 0.80 mol of B are mixed in 1 L, what are the concentrations for A, B, C, and D after reaction?
******Show work, no Exel/Spss please!!!!****** Variable B Variable A    1    2    3   ...
******Show work, no Exel/Spss please!!!!****** Variable B Variable A    1    2    3    1 5 4 4 2 6 9 1 3 7 4 1 5 2 3 4 2 6 6 5 2 7 7 3 4 5 3 3 4 2 3 8 1. Given the following data, what is the value of F crit for the column effect (variable b) *Hint: don't forget to evaluate a numerator (for variable B) and denominator df (within):...
Use boolean algebra to prove that: (A^- *B*C^-) + (A^- *B*C) + (A* B^- *C) +...
Use boolean algebra to prove that: (A^- *B*C^-) + (A^- *B*C) + (A* B^- *C) + (A*B* C^-) + (A*B*C)= (A+B)*(B+C) A^- is same as "not A" please show steps to getting the left side to equal the right side, use boolean algebra properties such as distributive, absorption,etc
Variable 1 Variable 2 Variable 3 Variable 1 Variable 2 - .18 Variable 3 - .30...
Variable 1 Variable 2 Variable 3 Variable 1 Variable 2 - .18 Variable 3 - .30 .27 Variable 4 - .74* .60* .34 Note: * = p < .05 A) What is the proportion of variance in variable 1 that is predicted by variable 3? B) What is the proportion of the variance in variable 2 that is not predicted by variable 4? What are the steps I need to take to solve this problem?
1. The rate constant for the reaction 2A → B is 7.25 × 10−3 s−1 at...
1. The rate constant for the reaction 2A → B is 7.25 × 10−3 s−1 at 110 ° C. The reaction is first order in A. How long (in seconds) will it take for [A] to decrease from 1.81 M to 0.750 M? 2. The following reaction, 2A → B is first order in A and has a rate constant, k, of 7.5 × 10−3 s−1 at 110 ° C. With a starting concentration of [A] = 1.65 M, what...
3. Let A = D + 1, B = D − 3, C = D +...
3. Let A = D + 1, B = D − 3, C = D + x, where D = dx. Calculate the differential operators AB, BC, CA and their effect on y(x) = e^3x
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT