Python Interview questions - magic methods
(Python version 3.9 or later version)
Which of the following Python objects is immutable?
set
dict
list
str
What would be the result of executing the following code?
print(True*2)
TrueTrue
True True
2
Syntax Error
Python Interview Questions
  • Python - Magic Methods
    1. What is the magic method for addition?
    A) __add__
    B) __+__
    C) __sum__

    Answer: __add__
    2. What is the magic method for greater than or equal?
    A) __gte__
    B) __ge__
    C) gte

    Answer: __ge__
  • gk