How to write comments in python?
Comments are the most basic thing in any coding language. It makes the code more understandable.
Even if we are reading a program after long time we can easily understand it with the help of comments.
There are two types of comments:-
- Single line comment
- Multiline comment
Hash “#” is used to write the comment. Interpreter omits whatever written after #.
e.g., (single line comment)
#addition of two numbers a=2 b=5 print(a+b)
e.g., (multiline comment)
#multiline comment #addition of two numbers a=2 #value of a b=5 #value of b print(a+b)
There is one more thing in python i.e., docstring. Docstring is not a comment. It is written in triple inverted commas “”” “””.
If it is written before code it will not be back in output but if it is written after code it will be back in output.
This is all about comments in python.
Subscribe
Login
Please login to comment
0 Discussion