Question: Create a class to represent one Die. The initializer should allow you to specify how many sides the die has. The initializer should also include

Create a class to represent one Die.
The initializer should allow you to specify how many sides the die has.
The initializer should also include an instance attribute to store the die's current face value.
Create an instance functionvalue()that returns the current face value of the die.
Create an instance function roll() that simulates rolling the die to randomly create a value based on the number of sides.
Hint ... where do you store this value?
Code the following instance functions. These instance methods allow comparison between two dice.
__str__
__repr__
__eq__
__ne__
__lt__
__gt__
__le__
__ge__

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 Programming Questions!