Question: : : # Write the WOFComputerPlayer class definition (part C) here class WOFComputerPlayer(WOFPlayer): SORTED_FREQUENCIES = 'ZQXJKVBPYGFWMUCLDRHSNIOATE' def __init__(self, name, difficulty): WOFPlayer.__init__(self, name) self.difficulty = difficulty

: : # Write the WOFComputerPlayer class definition (part C) here class WOFComputerPlayer(WOFPlayer): SORTED_FREQUENCIES = 'ZQXJKVBPYGFWMUCLDRHSNIOATE' def __init__(self, name, difficulty): WOFPlayer.__init__(self, name) self.difficulty = difficulty def smartCoinFlip(self): randnum = random.randint(1, 10) if self.difficulty > randnum: return True else: return False def getPossibleLetters(self, guessed): output = [] try: for c in LETTERS: if c.lower() not in guessed and c not in guessed and c in VOWELS and self.prizeMoney >= 250: output.append(c) elif c.lower() not in guessed and c not in guessed and c not in VOWELS: output.append(c) except Exception as e: print("Error", e) return output def getMove(self, category, obscuredPhrase, guessed): if guessed == []: return 'pass' elif self.smartCoinFlip() == True: return SORTED_FREQUENCIES[-1] elif self.smartCoinFlip() == False: return random.choice(self.getPossibleLetters(guessed)) 

=================

I have to define a class variable 'SORTED_FREQUENCIES'.

But when I define a class variable in the class 'WOFComputerPlayer', I can't call the variable within a method.

Why I can't call the class variable which is 'SORTED_FREQUENCIES' within a method(getMove)?

Is there a way to define a class variable and also use it within a method ?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!