πŸ“Š Python
Q. What happens if __str__() is not defined in a class?
  • (A) __repr__() is called as fallback
  • (B) Compilation error
  • (C) Returns empty string
  • (D) Program crashes
πŸ’¬ Discuss
βœ… Correct Answer: (A) __repr__() is called as fallback

Explanation: Python will fallback to __repr__() if __str__() is not defined.

Explanation by: Mr. Dubey
Python will fallback to __repr__() if __str__() is not defined.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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