top of page

Python Statement

Instructions that a Python interpreter can execute are called statements. For example, a = 1is an assignment statement.

Multi-line statement

In Python, end of a statement is marked by a newline character. But we can make a statement extend over multiple lines with the line continuation character (\). For example:

a = 1 + 2 + 3 + \
    4 + 5 + 6 + \
    7 + 8 + 9


This is explicit line continuation. In Python, line continuation is implied inside parentheses ( ), brackets [ ] and braces { }. For instance, we can implement the above multi-line statement as

a = (1 + 2 + 3 +
    4 + 5 + 6 +
    7 + 8 + 9)


Here, the surrounding parentheses ( ) do the line continuation implicitly. Same is the case with [ ] and { }. For example:

colors = ['red',
          'blue',
          'green']


We could also put multiple statements in a single line using semicolons, as follows

a = 1; b = 2; c = 3

Python Comments​


Python supports two types of comments:

1) Single lined comment:

In case user wants to specify a single line comment, then comment must start with ?#?

# This is single line comment.  

2) Multi lined Comment:

Multi lined comment can be given inside triple quotes.

''''' This 

    Is 

    Multiple comment'''  

© 2015 Thirumurugan

bottom of page