πŸ“Š Python
Q. What is true about `__str__()` in a class?
  • (A) It converts the object to an integer
  • (B) It returns a string representation of the object
  • (C) It destroys the object
  • (D) It initializes the object
πŸ’¬ Discuss
βœ… Correct Answer: (B) It returns a string representation of the object

Explanation: `__str__()` defines the string representation of an object when `str()` or `print()` is called.

Explanation by: Mr. Dubey
`__str__()` defines the string representation of an object when `str()` or `print()` is called.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
51
Total Visits
πŸ“½οΈ
8 mo ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
86%
Success Rate