Python Quest

Track 5 · Lesson 7 of 12

Docstrings and type hints

Document what a function does with a docstring and what it expects and returns with type hints.

About 30 minBeginner4 exercises

You will be able to

  • Write a docstring that says what a function does, what it takes and what it returns
  • Read a function's documentation with help() and __doc__
  • Annotate parameters and return values with basic type hints such as int, str, float, bool, list[int] and None
  • Explain that Python does not enforce type hints at run time

Included with a Formula Quest membership

It has 4 graded exercises with feedback, hints and solutions. Python Quest is included in Formula Quest memberships that cover Python; membership and billing are managed on Formula Quest.

View Formula Quest memberships

Tracks 1 and 2, the first lesson of every track, the playground and the dataset library are free.