How to and not to comment.

Comments are natural language text embedded in code that are meant for human understanding, not for computer execution. Here is a simple example:

`# Calculate BMI: weight (kg) / [height (m)]²bmi = weight_in_kg / (height_in_meters ** 2)`

Comments in programming are used for a variety of purposes such as a “note to self” to document specific implementation choices or to highlight areas that need review in the future. Comments are also important in collaborative settings where many developers work on the same project. They help developers understand the purpose of a piece of code, serving as a way of communication among developers. They can also help clarify the functionality of specific parts of the code or explain the purpose of a given function or routine.

Although comments can be highly useful and necessary in some cases, they can sometimes do more harm than good if not used properly. In this article, we will talk about how to make the best out of comments in programming as well as how not to use them.

`def moving_average(lst, n):    """    Calculate moving average over a given list with window size n.    """    ret = np.cumsum(lst, dtype=float)    ret[n:] = ret[n:] - ret[:-n]    return ret[n - 1:] / n`
`def calculate_area(radius):    # Changed from 3.14 to math.pi for more accurate results - 2022/09/15    # return 3.14 * radius * radius    return math.pi * radius * radius`