I am not stuck at any particular exercise, but I do have some conceptual questions which I wish to find out more about. I dug around in the forum archives but the other questions were mostly about how to debug a particular code/how to pass the exercise
Here are my questions:
Are objects and instances the same thing? I get the feeling that object is a broader term, but I am not really sure...In fact, one of the exercises mentioned something along the lines of "the first argument that
__init__()gets is used to refer to the instance object...."
Are functions under classes known as methods as well?
- When do you have to store an attribute under the parameter/argument(?) ?
In an earlier exercise (https://www.codecademy.com/en/courses/python-intermediate-en-WL8e4/0/5?curriculum_id=4f89dab3d788890003000096), there was such an example code:
class Square(object): def __init__(self): self.sides = 4 my_shape = Square() print my_shape.sides
but all subsequent exercises follow this format instead:
class Animal(object): def __init__(self, name): self.name = name zebra = Animal("Jeffrey") print zebra.name
So why does the second example need 2 arguments in order to have an attribute, while the first only require one to have an attribute?
4.Oh and also, what is the point of creating a class since they work in a way that is very similar to functions? Why not just create a function and then call the function with different arguments instead?
Thank you very much!