defining classes how many sides it has its current value when new msdie is createdwe specify how many sides it will haven we can then operate on the die through three provided methodsrollto set the die to random value between and ninclusivesetvalueto set the die to specific value ( cheat)and getvalueto see what the current value is here is an interactive example showing what our class will dodie msdie( die getvalue( die roll(die getvalue( die msdie( die getvalue( die roll(die getvalue( die setvalue( die getvalue( do you see how this might be usefuli can define any number of dice having arbitrary numbers of sides each die can be rolled independently and will always produce random value in the proper range determined by the number of sides using our object-oriented terminologywe create die by invoking the msdie constructor and providing the number of sides as parameter our die object will keep track of this number internally using an instance variable another instance variable will be used to store the current value of the die initiallythe value of the die will be set to be since that is legal value for any die the value can be changed by the roll and setroll methods and returned from the getvalue method writing definition for the msdie class is really quite simple class is collection of methodsand methods are just functions here is the class definition for msdiemsdie py class definition for an -sided die from random import randrange class msdie