

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do we provide comments in Python?
Comment is a text in a computer program that is a programmer-readable explanation or annotation in the source code. It is ignored by compiler/interpreter.
In Python script, the symbol # indicates start of comment line. It is effective till the end of line in the editor. If # is the first character of line, then entire line is a comment. It can be used in the middle of a line. Text before it is a valid Python expression, while text following it is treated as comment.
#this is a comment print ("Hello World") print ("Welcome to TutorialsPoint") #this is also a comment but after a statement.
In Python, there is no provision to write multi-line comment, or a block comment. Each line should have # symbol at the start to be marked as comment. Many Python IDEs have shortcuts to mark a block of statements as comment.A triple quoted multi-line string is also treated as comment if it is not a docstring of a function or class.
''' comment1 comment2 comment3 ''' print ("Hello World")
- Related Questions & Answers
- How do we create multiline comments in Python?
- How do we use single line comments in JavaScript?
- How do we use multi-line comments in JavaScript?
- Comments in Python
- How do we compare Python Dates?
- How do we declare variable in Python?
- How do we define tuple in Python?
- How do we define lists in Python?
- How do we define dictionary in Python?
- How do we reference Python class attributes?
- How do we use Python in interactive mode?
- How do we use Python in script mode?
- How do we return multiple values in Python?
- How do we use double quotation in Python?
- How do we compare two lists in Python?