def __init__(selfsides)self sides sides self value def roll(self)self value randrange( ,self sides+ def getvalue(self)return self value def setvalue(selfvalue)self value value as you can seea class definition has simple formclass each method definition looks like normal function definition placing the function inside class makes it method of that classrather than stand-alone function let' take look at the three methods defined in this class you'll notice that each method has first parameter named self the first parameter of method is special--it always contains reference to the object on which the method is acting as usualyou can use any name you want for this parameterbut the traditional name is selfso that is what will always use an example might be helpful in making sense of self suppose we have main function that executes die setvalue( method invocation is function call just as in normal function callspython executes four-step sequence the calling program (mainsuspends at the point of the method application python locates the appropriate method definition inside the class of the object to which the method is being applied in this casecontrol is transferring to the setvalue method in the msdie classsince die is an instance of msdie the formal parameters of the method get assigned the values supplied by the actual parameters of the call in the case of method callthe first formal parameter corresponds to the object in our exampleit is as if the following assignments are done before executing the method bodyself die value the body of the method is executed control returns to the point just after where the method was calledin this casethe statement immediately following die setvalue(