Header Ads

What are Comments in Python? Single Line and Multi Line Comments in Python


What is Comments in Python?


  • Comments are the line of program that are not executed.
  • Comments can be used to explain the code of Program
  • Comments can be used to make the code more readable
  • The compiler ignores comments line and does not include them in the executable program

How to Create Comments in Python
Comments start with # (hash sign)Anything that is written on right side of Hash sign is considered as comments 


Type of Comments in Python
There are Two Type of Comments in Python
        1. Single Line Comments
        2. Multi Line Comments

Single Line Comments

Comments on single line are added by #(Hash Sign)  . Anything that is written on right side of Hash sign is considered as comments and compiler ignored these line during Execution


# This is Single Line Comments

print("Hello World")


Multi Line Comments

If you Want to comment more than one line are called multi Comments. You can used triple quoted (Single quote or Double quote) Strings as a multi-line comments

"""
This is Multi Line Comments
Used For More Than one Line
used in Python
"""
print("Hello World")


No comments

Powered by Blogger.