Skip to content
This repository was archived by the owner on Sep 12, 2025. It is now read-only.
This repository was archived by the owner on Sep 12, 2025. It is now read-only.

3.02 use of comments instead of docstring #414

@Dan-TEALS

Description

@Dan-TEALS

Discussed in #346

Originally posted by jdonwells February 11, 2022
Python has something called a docstring to add documentation to a function in a standardized way.
3.02 shows this:

# Name: multiply_by_two
# Purpose: multiplies a given number by 2
# Input: number to multiply (int)
# Output: int
def multiply_by_two(a): 
  c = a * 2
  return c

Instead, I would recommend this:

def multiply_by_two(a): 
  """
  Name: multiply_by_two
  Purpose: multiplies a given number by 2
  Input: number to multiply (int)
  Returns: int
  """
  c = a * 2
  return c

Many IDEs will know about docstrings and display them as you write code.

Metadata

Metadata

Assignees

Labels

BugIntroCS.2Low SeverityCosmetic issue that doesn't affect usability of a lesson

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions