Quotation in Python,Comments in Python…
- Jino Shaji
- Jan 17, 2015
- 1 min read
Updated: Jun 9, 2020
Quotation in Python:
Python accepts single (‘), double (“) and triple (”’ or “””‘) quotes to denote string literals, as long as the same type of quote starts and ends the string.
The triple quotes can be used to span the string across multiple lines.
For example,
all the following are legal:
word = ‘word’
sentence = “This is a sentence.”
paragraph = “””This is a paragraph. It is made up of multiple lines and sentences.”””
Comments in Python:
A hash sign (#) that is not inside a string literal begins a comment. All characters after the # and up to the physical line end are part of the comment and the Python interpreter ignores them. #!/usr/bin/python
# First comment
print “Hello, Python!”;
# second comment
This will produce the following result:
Hello, Python!
A comment may be on the same line after a statement or expression:
name = “Madisetti”
# This is again comment
You can comment multiple lines as follows: # This is a comment. # This is a comment, too. # This is a comment, too. # I said that already.
Using Blank Lines:
A line containing only white-space, possibly with a comment, is known as a blank line and Python totally ignores it. In an interactive interpreter session, you must enter an empty physical line to terminate a multi line statement
Comentários