Practice mode Python

Where is a docstring written as the first statement of a function stored?

Correct answer A. In the function's __doc__ attribute

Explanation

A string literal that is the first statement in a module, class or function body becomes its docstring and is stored in the __doc__ attribute, which help() displays. Unlike a # comment, it is kept at runtime. __name__ holds the function's name, not its documentation.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.