Hi, i am currently trying to learn how to program in python and i have been doing ok until now! I am confused about classes objects and methods, i understand most of how they work.
In a question task I am asked to create some code for a die (singular of dice), and it says that i have to include the following:
"Die.__init__(self)" to initialise an attribute called 'value' to 1.
I've seen things like def__init__(self) before but I don't get Die.__init__, does anyone know what this means? And initialising a value to 1 through this, does that just mean I'm writing that the value is 1 or is this similar to a function?? V.confused!
Another thing I've got to include is Die.__str__(self) again with the Die.__str__ i am unsure of what this means! It says this should return a message saying that it's an object of the Die class and stating the current value.
And finally I get asked about Die.throw(self), ive noticed this doesn't have the __ underscore's so i'm thinking this is something else? This one is supposed to set the value attribute at a random integer in the range 1 to 6 and return that value. when it says return that value i think function, am i thinking right?
don't worry if you can't help however if you can i would appreciate any tips and hints!
thanks very much