Class - Object


class Animal(object):
    def __init__(self,name): = name
zebra = Animal("Jeffrey")


Can anybody help me understand the code how it works as i am new to programming

Replace this line with your code.


a class is like a blue print, it describe something. In this case, an animal.

in this case, your animal has a name. When you create a class instance:

zebra = Animal("Jeffrey")

you create an actual animal with a name. When creating a class instance, the init() method is called


Thank you , got that

Ex :Dog is a class , bark is a method and Pomeranian is an instance of Class (Dog)


yes, indeed :slight_smile: Well done :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.