GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — __init__ in Python - GeeksforGeeks __init__ in PythonLast Updated : 11 May, 2026 __init__() method is a constructor which is automatically called when a new object of a class is created. Its main purpose is to initialize the object’s attributes and set up its initial state. When an object is created, memory is allocated for it and __init__ helps organize that memory by assigning values to attributes. Let’s look at some examples. __init__() with ParametersYou can pass parameters to initialize multiple attributes.
Output Max 30 Emilia 25 Explanation:
Default Parameters in __init__()Like regular functions, __init__() can have parameters with default values.
Output Buddy Mixed 1 Max Golden Retriever 5 Explanation:
__init__() Method with InheritanceWhen using inheritance, both parent and child classes can have __init__() methods.
Output A init called B init called Explanation:
Related Articles:Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |