How do one or two green pockets turn a fair wheel into a losing bet, and how do variance and standard deviation measure the spread?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
FairRoulette is given. Define EuRoulette, a subclass of FairRoulette whose wheel also has the pocket '0' and whose __str__ returns 'European Roulette'. The payoff must stay what FairRoulette sets.
import random
class FairRoulette():
def __init__(self):
self.pockets = []
for i in range(1, 37):
self.pockets.append(i)
self.ball = None
self.pocketOdds = len(self.pockets) - 1
def spin(self):
self.ball = random.choice(self.pockets)
def betPocket(self, pocket, amt):
if str(pocket) == str(self.ball):
return amt * self.pocketOdds
else:
return -amt
def __str__(self):
return 'Fair Roulette'