33 lessons
Python · Module 6Module material

Objects and Classes interview questions

25 questions interviewers ask on this module’s topics, from first principles to the follow-ups. Each comes with a model answer.

Classes and objects

  1. What is the difference between a class and an instance?●
  2. What is self?●
  3. What does __init__ do? Is it the constructor?●
  4. What happens if a method has no self parameter?●●
  5. Where are an object's attributes stored?●●
  6. Why is setting a misspelt attribute dangerous?●●
  7. What is the difference between == and is for your own objects?●●
  8. What are special methods (dunder methods)? Give examples.●●
  9. What is the difference between __repr__ and the default display?●●
  10. "Everything in Python is an object." What does that mean in practice?●

Inheritance

  1. What is inheritance?●
  2. What does super().__init__(...) do, and what happens without it?●●
  3. How do you define a custom exception, and why subclass a built-in one?●●

Dataclasses

  1. What does @dataclass generate?●
  2. Does a dataclass check its type hints?●●
  3. Why can a dataclass field not have [] as its default?●●
  4. What does frozen=True do, and when would you use it?●●
  5. What is a decorator?●●

The estimator pattern

  1. What is the estimator pattern?●
  2. Why do learned attributes end in an underscore?●●
  3. Why does fit return self?●●
  4. What is the difference between a parameter and a hyperparameter?●●
  5. How does k-nearest neighbours regression predict?●●
  6. Why should fit store a copy of the data it is given?●●
  7. Why is a model's error on its own training data a poor measure?●●

Directory listings

  • SchoolWhool on Siteefy