Python Interview questions - Object-oriented programming
(Python version 3.9 or later version)
Which of the following is NOT a difference between a method and a function?
Functions are not associated with any object. Methods are associated with the objects of the class they belong to
A function is an independent entity, so can be invoked just by its name. A method is called with reference to an object. It cannot be invoked just by its name.
All function are methods while all methods are not functions
Functions do not require any ‘self’ argument. A method requires to have ‘self’ as its first argument.
Python Interview Questions
  • Python - Objects & Classes
    1. How do you define that your Mammal class inherits from Animal?
    A) Mammal(Animal)
    B) Mammal.Animal
    C) @Animal.Mammal

    Answer: Mammal(Animal)
  • gk