Question: USE PYTHON CODING import random class Die: face_value=1 def show(self): return [+str(self.face_value)+] def getFaceValue(self): return self.face_value def roll(self): self.face_value=random.randint(1,6) Using the code shown above as
USE PYTHON CODING
import random
class Die:
face_value=1
def show(self):
return "["+str(self.face_value)+"]"
def getFaceValue(self):
return self.face_value
def roll(self):
self.face_value=random.randint(1,6)
Using the code shown above as a base write a code to do the following:
- Make a change to the Coin class to add the method flip(), which randomly assigns Heads or Tails to a Coin object
- Create a function ThreeMatches which when creates 3 coin objects and flips them every time the user presses Enter. The function should stop if all three coins show the same value.
- Make a change to the Die class to add a method setSize which allows the number of faces to be set. (eg. Allow a 12 sided die or an 8 sided die to be created)
- Create a list containing one hundred Dice (100 Die objects). Create a function that rolls all the dice in the list then counts up how frequently each value occurs.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
