LearnFrenzy
Sign in Take a free test

Python Basics and Syntax · Python Basics MCQ · Question 10

What is a docstring? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 10 Back to Exercise

Which statement about docstrings is correct?

  • A Any comment that starts with ##
  • B A comment that Python removes before compiling
  • C A string that must be passed to print()
  • D A string literal that is the first statement of a module, function or class; it is stored in __doc__ Correct
Correct Answer: Option D

Docstrings are real string objects kept at run time – help() and IDEs read them from __doc__. Comments, in contrast, are discarded.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links