import random # You can find the python comment standards at https://www.python.org/dev/peps/pep-0008/#comments. # Comments should be complete sentences, starting with a capital letter and ending with a period. # Inline (on the same line as code) comments can be sentence fragments, but they should be useful. f = 48 # f equals 48 (bad!) c = (f - 32) * 5.0/9.0 # Convert fahrenheit to celsius (good!) for i in range(0, 5): for j in range(0, 5): # Do some stuff. # Block comments should always be indented to the same # level of the code it refers to. Don't use triple quotes # in the middle of code - thats for docstrings. print(i*j, " ", end="") print() def get_random(): """Return a random number. This string will is stored in the special __doc__ attribute on the function get_random. Notes: - Docstrings should be in command form (e.g. "Calculate area" instead of "Calculates area"). - For multiline strings, the ending closing quote should be on a new line. - All public classes, modules, or methods should have docstrings, but commenting your private methods is still a good idea! """ return random.random() def do_something(): """Print something.""" print("Note that a single line docstring has quotes all on one line.") print("get_random() Docstring:") print(get_random.__doc__) print("\n\ndo_something() Docstring:") print(do_something.__doc__)