Python Programming – Python Statement

Instructions that are executed by Python interpreters are called statements. For instance, count=l represents an assignment statement, while, and for are looping statements.

Multiline Statements

In Python language, the end of a statement is marked by a newline character. But, a statement can be continued over multiple lines with the continuation character (\). For instance,

sum= 10+20+30+\
40+50+60+\
70+80+90

The above statement is an explicit line continuation. In Python language, line continuation is implied inside the parenthesis  ( ), brackets  [ ], and braces { } . For instance, we can also implement the above multiline statement as a

sum= (10+20+30+
40+50+60+
70+80+90)

Here, the surrounding parenthesis ( ) does the line continuation implicitly. Similarly [ ] and { } can be used. For instance,

shape=[‘rectangle’,
‘square’,
‘triangle’]

Multiple statements can be written in a single line as follows, where semicolon; works as a separator

a=1; b=2; c=3

Python Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *