Python Comments Tutorial | Types of Python Comments

The ability to comment on the source code appears in all programming languages. A comment is a non-executable line of text, this means that the compiler or interpreter will not take it as a line of code. the comments. In Python, as well as in other programming languages, they serve to leave small explanations about what the program does. We know that it is very difficult to remember every aspect of our program, especially when we work on long and complicated projects. Python, being a simple language in syntax issues, helps us to properly document our code without much effort. This is a necessary practice and good developers will make great use of comments. Without this, the source code can get confusing really fast.


Types of Python Comments


Types of Python Comments:


In Python make comments in two ways. Writing the numeral symbol (#) at the beginning of the line of text where we want our comment. By typing triple quotation marks (') at the beginning and end of the comment , in this case the comments may occupy more than one line.

Let's see examples:

Single line comments in Python


# This is a comment in Python
>>> function_1 ( )
>>> funcion_2 ( ) # Comments can also be after an executable text

# This is another comment in Python.
# You can have so many single line comments in a row.


Multi-line comments in Python:


"" "This is a multi-line comment.
We can write as many lines as we want by way of documentation. "" "
function_3 ( )
function_4 ( )

'' 'We can also make multi-line comments with single quotes.' ''.

Get to know more about the impact of Python on various domains by being a part of the best Python training institute in Bangalore.

Comments

Post a Comment

Popular posts from this blog

Python Programming Language Introduction - How to learn Python for Beginners?

Interesting Facts About Python Programming Language