Python Comments and Statements

Filed Under: Python

So, in this tutorial, we are going to learn about Python Comments and Statements. We’ll talk about what Python comments are, the different types, and how you can define them. We also have a brief section that demonstrates Python statements.

Previously we learned about Keywords and Identifiers in Python.

What are Python Comments?

Python comments are strings that begin with the # (hash/pound sign). They are used to document code and to help other programmers understand the same. You can use Python comments inline, on independent lines, or on multiple lines to include larger documentation.

These comments are statements that are not part of your program. For this reason, comment statements are skipped while executing your program.

Usually we use comments for making brief notes about a chunk of code. Also comments are important so that other can understand easily while reading your program. On the other hand, comments are also useful for the programmer himself. One can understand a program done a long time a ago simply from the comments of the program.

Here’s an example of comment-

#this is a Python comment. I can write whatever I want here

#print("I will not be executed")

print("I will be executed")

python statement, python comment example output

If you run this, then you will see output will be like this below picture-

So you can see the lines starting with # are not executed. Those are the comments.

Different Types of Python Comments

In Python there are two types of comments- Single line comments and Multiple lines comments. Single line commenting is commonly used for a brief and quick comment (or to debug a program, we will see it later). On the other hand we use the Multiple lines comments to note down something much more in details or to block out an entire chunk of code.

1. Single Line Comments

In Python for single line comments use # sign to comment out everything following it on that line.

#this is a comment

myVar = "hello comments" # a variable containing something

print(myVar) #print statement to print contents of a variable

2. Multiple Lines Comments

Multiple lines comments are slightly different. Simply use 3 single quotes before and after the part you want to be commented.


print("I am in Multiple line comment line 1")

print ("I am in Multiple line comment line 2")


print("I am out of Multiple line comment")

What are Python Statements?

Statements are logical lines we write in our code. Statements can be like below.

  1. Assignment Statement: myVariable1=”hello world” myVariable2=100 myVariable3=12.23
  2. Addition Statement: myVariable4=myVariable2 + myVariable3
  3. Subtraction Statement: myVariable4=myVariable2 – myVariable3
  4. Multiplication Statement: myVariable4=myVariable2 * myVariable3
  5. Division Statement: myVariable4=myVariable2 / myVariable3

And many more. These are only some examples.


Alright! That’s all for this tutorial on Python comments and statements. Try to run every piece of code snippet given here in your own machine. As there’s an old saying – “if you want to learn how to swim, jump into the water”. #happy_coding 馃檪

In our next tutorial, let’s talk about the different data types in Python.


  1. tejkrishna says:

    Amazing!! Thank you a lot!! It’s more or less how I thought it should be, now I can continue with the project

  2. sameer says:

    python language is one of the peak demand in the IT field. .Types of Python Comments article which is very helpful thanks for sharing your efforts

  3. bdevils464 says:

    Thanks for publishing python information. This is very understanding and useful to me

  4. Kelly Technologies says:

    Inspirational content, have achieved a good knowledge from the above content on Python Training useful for all the aspirants of Python Training.

  5. Terry says:

    Hi Dev, Your tutorial is excellent for beginners. I have a feedback. At the bottom of “Python Keywords and Identifiers” page, the next page link goes to Android CollapsingToolbarLayout Example rather than “Python Data Types”.


    1. Kuhak Chakraborty says:

      Yes, because this is wordpress blog, so this shows according to publishing time.

  6. Python says:

    Thanks for publishing python information. This is very understanding and useful to me

Leave a Reply

Your email address will not be published. Required fields are marked *

Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages