Q:

Let A and B be objects of class Foo. Which functions are called when print(A + B) is executed?

0

Let A and B be objects of class Foo. Which functions are called when print(A + B) is executed?

The function __add__() is called first since it is within the bracket. The function __str__() is then called on the object that we received after adding A and B.


  1. __add__(), __str__()
  2. __str__(), __add__()
  3. __sum__(), __str__()
  4. __str__(), __sum__()

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Correct Answer:

__add__(), __str__()

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now