Functions’ good practices


Here’s a list of good practices that you can follow to improve the robustness and readability of your code:


def p_0_or_1(bool p)
  pass


This is not a good name for the function since it does not inform us about its content, it does not clearly describe what the function does or what it is used for. A good function name should be descriptive, easy to understand, and should clearly convey the purpose of the function.

def print_on_intersection(bool isIntersected)
  pass


This is not a good name for the function since it does not inform us about its content, it does not clearly describe what the function does or what it is used for. A good function name should be descriptive, easy to understand, and should clearly convey the purpose of the function.




def calculate_beam_volume(length, width, height):
  """
  This function calculates the volume of a beam
  """
  volume = length * width * height
  return volume




def calculate_beam_volume(length: float, width: float, height: float) -> float:
  """
  This function calculates the volume of a beam
  """
  volume = length * width * height
  return volume