 In this lesson, you’ll see what makes a good comment. You’ll learn conventions for writing

• Docstrings

You’ll learn how to write block comments that span multiple paragraphs:

``````def quadratic(a, b, c, x):
# Calculate the solution to a quadratic equation using the
#
# There are always two solutions to a quadratic equation,
# x_1 and x_2
x_1 = (- b+(b**2-4*a*c)**(1/2))
x_2 = (- b-(b**2-4*a*c)**(1/2))
return x_1, x_2
``````

Next, you’ll see why inline comments can be unnecessary and distracting if they state the obvious. You’ll learn how to write useful inline comments without cluttering your code:

``````# Don't do:

x = 'John Smith' # Student Name

# Do:

student_name = 'John Smith'
``````

You’ll also cover how to write documentation strings:

``````def quadratic(a, b, c, x):

A quadratic equation has the following form:
ax**2 + bx + c = 0

There are always two solutions to a quadratic equation:
x_1 and x_2.
"""

x_1 = (- b+(b**2-4*a*c)**(1/2))
x_2 = (- b-(b**2-4*a*c)**(1/2))

return x_1, x_2
`````` Ignat Domanov

side comment: both x_1 and x_2 in

``````x_1 = (- b+(b**2-4*a*c)**(1/2))
x_2 = (- b-(b**2-4*a*c)**(1/2))
``````

should be divided by 2*a

to join the conversation.