Nov-27-2019, 07:20 AM
(This post was last modified: Nov-27-2019, 07:20 AM by leodavinci1990.)
from random import Random # library for randoms class Die(object): # define the class sides = [1,2,3,4,5,6] def __init__(self): # METHOD self.sideShowing = Die.sides[0] # PROPERTY def roll(self): # METHOD newSide = Random().choice(Die.sides) self.sideShowing = newSide # PROPERTY1.Why is there an object in parentheses at the class definition (line 1) ? what is this object and why is it passed as an argument-is it a special type of argument or just the name of an argument?
2.What is the self in parentheses at lines 4 and 7?
3.What is the _init_ method?