Python Statements

Python Multiline Statements

In Python, a single statement is written in a line. If you are writing a statement that comes in multiple lines then the code written in the second line will be treated as a separate statement. It may be possible to generate error.

To write a statement in multiple lines, the line continuation character is used in Python.

if num == 0
and sum == 100:
print("Something is wrong")

If the statement is written in brackets such as [], {}, (), then you do not need line continuation character to write it in multiple lines.

Single Line Multiple Statements

By the way, a single statement is written in a line in python. But if you want to define multiple statements in a line, then you use semicolon for this.

You define semicolon after a statement and then you write the second statement. From this python interprets those statements separately.

print("first statement");print("second statement")

After all, there is no need to define semicolon after the statement.

Python Quotes for Strings

To define strings, single (‘), double (“) and triple (” “”) quotes are used in python. Single and double normal single lines are used for strings.

msg = 'Python is Best Language.'
msg2 = "Python is different Language."