how to comments in python

 


Comments in Python.

In this post we are going to learn about Comments in Python. Let's start..!

First of all What is comments ? 

Comments is a simple text that we write in code. And this text always start with special character '#' .

for example.

here you can see I have written a normal text starting with '#'  This is comment.



Something you should know about Comments.

1} Python comments should be start with a special character i.e. '#'  .

2} The text you will write as a comment that will be ignored by Python interpreter. or All the text written after '#' in that single line will be ignored by interpreter.

3} For commenting multiple lines we use triple single quote ( '''   ''' ) but that is not recommended . You can use that but that is not standard way to use comments. The standard way of using comments is starting with '#' . 






Now Why we need Comments in program ? 

Actually comments are so important in program because in actual world of Information Technology we writes a thousand lines of code and if you want to edit something or wants to change in that how you will know Why I write this method ? or What actually this function does ? to overcome this problem we writes a  comments means we writes some information about that method there in code. Then we can understand what that methods does.

Advantages and uses of comments in Python.

Here some important points on Why we should write comments in program ? 
1] Using comments you can write some description about your program there in code.
2] If you give your program to any other person then that person can understand how actually you build that logic or How your program will work.
3] If you open your program after a month or after some time. then you will not understand what logic actually you had used there. But you can overcome such problems using comments in your program.  

and many more advantages of writing comments. Once you started coding you will understand all advantages.



What is datatypes in python ? or What are different types of datatypes ? That we will see in next post.


If you have any doubts in this post then please ask me in comment section below. I will try to solve it.


If you like these post and you have learned something from this then share this post with your friends and family.

Keep learning always.....!!! 😇😇😇





Previous Post  Next Post