1. Learn
  2. /
  3. Courses
  4. /
  5. Python으로 함수 작성하기

Connected

Exercise

동료의 코드 리뷰하기

동료가 프로덕션 준비를 위해 자신이 작성한 코드를 리뷰해 달라고 부탁했어요. 유지 보수성과 재사용성이 좋은 함수를 위해서는 docstring을 작성하는 것이 모범 사례라는 것을 알고 있으므로, sanity check 차원에서 이 has_docstring() 함수를 동료의 모든 함수에 적용해 보려고 합니다.

def has_docstring(func):
  """Check to see if the function 
  `func` has a docstring.

  Args:
    func (callable): A function.

  Returns:
    bool
  """
  return func.__doc__ is not None

Instructions 1/3

undefined XP
  • 1

    동료의 load_and_plot_data() 함수에 has_docstring()을 호출하세요.

  • 2
    • 함수 as_2D()에 docstring이 있는지 확인하세요.
  • 3
    • 함수 log_product()에 docstring이 있는지 확인하세요.