<jupyter_start><jupyter_text>3.1 Comments and Docstrings Comments are used to explain the code. The interpreter doesn't execute the comments. There are 3 types of comments in Python: * Single Line* In-Line* Multi Line  Single LineSingle line comments are written in a single line. Single line comments start with `````Python Here's a single line comment```  In-LineIn-Line comments are written beside the code.```Pythonprint("Hello")   Here's a In-Line comment```  Multi LineSometimes we need to write a huge explanation using comments, in those cases we do use multi-line comments. multiline comments are enclosed in `""" """` or `''' '''````Python"""Here's a multiline comment."""```  Docstrings Docstrings are specific type of comments that are stored as a attribute to the module, class, method or function.Docstrings are written similar to the multi-line comments using `""" """` or `''' '''`, the only difference would be they are written exactly at the start(first statement) of the module, class, method or function. Docstrings can be programatically acccessed using the `__doc__` method or through the built-in function `help`. Let's give a try 😎.<jupyter_code>def double_the_value(value: int):
    """Doubles the integer value passed to the function and returns it."""
    return value * 2<jupyter_output><empty_output><jupyter_text>Using help `help` function provides the docstrings as well as the information about the module, class, method or function.<jupyter_code>help(double_the_value)<jupyter_output><empty_output><jupyter_text>Using `__doc__`<jupyter_code>print(double_the_value.__doc__)<jupyter_output><empty_output><jupyter_text>Can we use the single line comments instead of multi-line docstrings 🤔? Let's try this as well.<jupyter_code>def test_single_line_comment_as_docstring():
    # This is a single-line comment
    pass
print(test_single_line_comment_as_docstring.__doc__)<jupyter_output><empty_output><jupyter_text>We can see that `None` is printed, which explains that we can't use single-line comments as docstrings 🙂  Docstrings for documentation of code. [PEP-257](https://www.python.org/dev/peps/pep-0257/) defines two types of docstrings.  * One-Line docstring* Multi-Line docstring  [One-Line docstring](https://www.python.org/dev/peps/pep-0257/one-line-docstrings) One-line docstrings are suited for short and simple Modules, classes, methods or functions.<jupyter_code>def one_line_docstring():
    """This is a one-line docstring"""
    pass<jupyter_output><empty_output><jupyter_text>[Multi-Line docstring](https://www.python.org/dev/peps/pep-0257/multi-line-docstrings) Multi-line docstrings are suited for long, complex Modules, classes, methods or functions<jupyter_code>def multi_line_docstring(arg1: int, arg2: str) -> None:
    """
    This is a multi-line docstring.

    Arguments:
      arg1 (int): Argument 1 is an integer.
      arg2 (str): Argument 2 is a string.
    """
    pass<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09891964888588792, 'fraction_numerical': 0.008440243079000676, 'mean_word_length': 5.372043010752688, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 26, 'https://': 3, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '503431', 'license': 'MIT', 'n_tokens_mistral': 889, 'n_tokens_neox': 852, 'n_words': 312, 'path': 'Chapters_1-5/Chapter_3/1_Comments_and_docstrings.ipynb', 'repo_name': 'NaveenKumarReddy8/MyPython', 'size': '2962'}