Question: In Python, create a class named Coin that inherits from the Die class below: Augment your previous submission with a new class named 'Coin'. Coin

In Python, create a class named Coin that inherits from the Die class below:

Augment your previous submission with a new class named 'Coin'. Coin should inherit from Die, with the following modifications;

  • The constructor should not take any arguments; a coin always has two sides
  • add a flip() method that uses the roll() method from the parent class. If roll returns 1; flip should return "HEADS". If roll returns a 2, flip should return "TAILS"
  • Do not override the roll or rollMultiple methods from the parent class
#!/usr/bin/python # Die and Coin classes go here from random import randint class Die(object): def __init__(self, sides): self.sides = sides def roll(self): return randint(1, self.sides) def rollMultiple(self, number): lst = [] for i in range(number): lst.append(self.roll()) return lst def getSides(self): return self.sides # testing code # please do not edit myCoin = Coin() if myCoin.roll() > 0 and myCoin.roll() < 3: print("test 1 pass") resFlip = myCoin.flip() if resFlip == 'HEADS' or resFlip == "TAILS": print("test 2 pass")

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!