Get startedGet started for free

Correct use of __init__

Python allows you to run custom code - for example, initializing attributes - any time an object is created: you just need to define a special method called __init__(). Use this exercise to check your understanding of __init__() mechanics!

Which of the code blocks will NOT return an error when run?

4 code blocks

This exercise is part of the course

Object-Oriented Programming in Python

View Course

Hands-on interactive exercise

Turn theory into action with one of our interactive exercises

Start Exercise