Comments in Python

Hello friends how are you, today in this blog i will teach you what is comment in Python, types of comment , how comment works and programs using comment in a very simple way.

Let's start

Comments in Python

  • Comments in Python are used to explain the code to make it more readable for the reader.
  • Comment is not considered as a part of program, in other word we can say that compiler ignores the comment.
  • Python comments are statements that are not executed by the compiler.
  • Generally comments are used to tell the user that what we have done in the program so that user can understand it in easy way.

Types of comments in Python

  • Single line comment
  • Multiline comment

Single line comment

  • It is used to comment only one line.
  • Hash symbol(#) is used for single line comment.
  • In a program if you want to comment only a single line then you can use it otherwise if you you want to comment many lines then you can go for multiline comment.
#this is a single line comment
print("you are excellent");

Multiline comment

  • Multiline comment is used to comment a block of code.
  • Triple quotes (""") are used to comment multiline.
  • Multiline comment starts with """ and ends with """.
  • The text between """ and """ is not executed by the compiler.

This is a multiline comment
Write a program to add two
numbers and stores it into
the third number
Sum= 80

Request:-If you found this post helpful then let me know by your comment and share it with your friend.

If you want to ask a question or want to suggest then type your question or suggestion in comment box so that we could do something new for you all.

If you have not subscribed my website then please subscribe my website.

Try to learn something new and teach something new to other.

Post a Comment