comment python multiple lines code example
Example 1: multiline comment python
# While Python doesn't support multi-line comments, it can ignore anything
'''
inside a multi-line string!
Just wrap the comment in the three single quote marks,
And
you're
good
to
go!
'''
Example 2: python comment multiple lines
#There is no way to comment multiple lines in Python.
#You just keep using "#" symbol to comment each line out.
'''
Technically you could also use triple single quotation
marks like so, but this formatting does not count
as "true" source code comments that are removed by
a Python parser.
'''
Example 3: python multiline comment
def increase_salary(sal,rating,percentage):
""" increase salary base on rating and percentage
rating 1 - 2 no increase
rating 3 - 4 increase 5%
rating 4 - 6 increase 10%
"""
Example 4: multiple comment line in python
'''
This is a multiline
comment.
'''
Example 5: python multi comment
"""Put comments inside triple quotes"""
Example 6: multiline comment in python
# Python is a language that doesn't support multiline comments
# In languages like JS, single line comments have
# and multiline comments have in the end
# the pound symbol in front of these five lines is the python equivalent of
print("But there is a workaround!!!")
"""
In python, multiline string is written with 3 double or single quotes,
and the characters in between are treated as an entire string
but, if this string isn't assigned to a variable, python doesnt give any error
It instead ignores the string, similar to the behaviour it would have
towards a comment.
BUT!!!!!
If this is string is put just after defining a function, it is treated as a
docstring, or the documentation string of that function. So, it does have a
meaning and is not exactly ignored by Python
"""
def someFUnc():
"""
Python will treat this as a docstring
"""
pass
print(someFUnc.__doc__)
# OUTPUT:
# Python will treat this as a docstring