Python Comments
Comment is documented text that are used to express the thinks of logic and functionality of codes. this is provide an readability to understand the logic of source code such as operation and functionality for other programmers. python interpreter is avoid and skips the comment portion because that is useful documentation for programmer.

Python is provide an opportunity to create comment in a two ways for programmer. first one is single line comment and another is multiple comment.
Type of comments
Comment are recognized in a two way.
Interactive mode comments
Single line comment are used to short description of code. this is starting with a # hash symbol. and after that has been informative text can used.
# Display welcome message for python programmer
print("Welcome to learning python") #simple message
Output
Welcome to learning python
observe that in this example are using of two single line comment. first comment are used to demonstrate purpose of program and another one provide information to statement. In similar way describe to short information using single line comments.
Multi-line comment :That is a sequence of single line comment in more than once.
#first line comment
#second line
#third line
#...
Script mode comments
Multi-line comment are generally used to describe significance of large and detailed explanation of operation. that is starting and ending with a (''') Triple quotes. and inside of this are text of comments. view its syntax.
''' this is multiline comment text
description
:
:
:
'''
for example
'''
This program are calculate factorial
of given number n by using of recursion.
function : factorial
parameter : one integer argument
return : one integer value
'''
def factorial(num):
# base condition when number is one
if(num==1):
return 1
else :
#recursive call factorial function
return factorial(num-1)*num
#display factorial of 5
print factorial(5)
Output
120
In this example given a function description within multiline text. Note that within multiline comment are allowed whitespace, symbols, alphabets and operator. the length of comment string are no limits.
Triple double quotation marks (""") is also used in a multi-line comments.
Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.
New Comment