Answer: Comments in Python are mainly of four types:
- Single-line comments
Example:Â
# List of numbers
numbers = [76, 5, 3, 68, 43, 23, 54, 42, 11]
- Multi-line comments
Example:
# Python code is
# easy to understandÂ
# with comments
- String literals as comments
Example:
""I can write a comment for list of numbers like this""
numbers = [76, 5, 3, 68, 43, 23, 54, 42, 11]
 Here, the sentence in the quotes is a string literal that acts as a comment. This is because it is not assigned to a variable.
- Python docstrings
Example:
def hello(name):
    """
    This function greets
    the person passed as
    a parameter
    """
    print("Hello, " + name + ". How are you?")
hello('Lisa')
 Output:
Hello, Lisa. How are you?
In the above code, the lines written between the triple quotes are a docstring, and they explain the hello() function.
Related Questions
- How do you comment out multiple lines in Python?
- What is the use of Del in Python?
- How do you define a function in Python?
- How do you declare a global variable in python?
- How do you find the range in Python?
- How do you sort a list in Python and Python 3?
- How do I reverse a list in Python?
- How do you Del statement in Python?
- What is function in Python with example?
- What is a global variable in python?
- What is __ Getattr __ in Python and what it is used for?
- How do you range a number in Python?
- How do you comment out a paragraph in Python?
- What is __ del __ in Python?
- What is the function of == in Python?
- Is it OK to use global variables in Python?
- What is Getattr and Setattr in Python?
- How does Range () work in Python?
- What does sort () do in Python?
- How do you reverse in Python 3?
- What do you mean by comments in Python?
- How do I delete a command in python?
- How do you declare a global list in Python?
- How do you sort a list in descending in python?
- How do you reverse a list without reverse?
Related Topics
- Python Lambda (Anonymous) Function
- Python *args and **kwargs (With Examples)
- Python Array of Numeric Values
- Python Assert Statement
- Python Comments (With Examples)
- Python del Statement (With Examples)
- Python Dictionary Comprehension
- Python Functions (def): Definition with Examples
- Python Function Arguments (Default, Keyword and Arbitrary)
- Python Global Keyword (With Examples)
- Python Global, Local and Nonlocal variables (With Examples)
- Python ascii()
- Python delattr()
- Python super()
- Python locals()
- Python hash()
- Python id()
- Python sorted()
- Python dict()
- Python callable()
- Python dir()
- Python next()
- Python divmod()
- Python float()
- Python bytearray()
- Python filter()
- Python issubclass()
- Python __import__()
- Python enumerate()
- Python list()
- Python input()
- Python int()
- Python complex()
- Python zip()
- Python iter()
- Python bool()
- Python hex()
- Python open()
- Python ord()
- Python Built-in Functions
- Python oct()
- Python compile()
- Python reversed()
- Python tuple()
- Python frozenset()
- Python map()
- Python setattr()
- Python len()
- Python chr()
- Python object()
- Python bytes()
- Python getattr()
- Python slice()
- Python str()
- Python sum()
- Python isinstance()
- Python bin()
- Python type()
- Python range()
- Python Dictionary items()
- Python List sort()
- Python List reverse()
- Python String strip()
- Python String join()
- Python String split()
- Python User-defined Functions
Leave a Reply