Class Init Method
Multiple Choice Beginner
Question
What is __init__ in a Python class?
Hint
__init__ initializes new objects.
Explanation
__init__ is the constructor method, called automatically when a new instance is created. It initializes the object attributes. The first parameter is always self (the instance). Example: class Dog: def __init__(self, name): self.name = name. Then Dog("Rex") creates an instance with name="Rex". __init__ does not return anything.
Related Resources
Related Lessons
- Classes
Learn Python classes.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.