You can learn about Operators in Python Programs with Outputs helped you to understand the language better.

Python Programming – Statements

A Python statement is an instruction or a unit of code that the Python interpreter can execute. In computer language, complete command is called a statement. Examples of the statement are:
>>> print(12 + 15) .
27
This is because you told the system to print the result of the expression 12 + 15, which is a complete statement. However, if you type :
>>> print(12 +) you will get a syntax error.

Other statements could be the following:
>>> print (“Welcome to the world of Python”)
Welcome to the world of Python
>>> print(“Sum of 2 + 5 = “, 2+5)
Sum of 2 + 5 = 7

The first statement asks Python to display string literal Welcome to the world of Python. In the second print statement, Python prints the part within quotes “Sum of 2 + 5 = ” followed by the result of adding 2 + 5, which is 7. To print multiple items on the same line, separate them with a comma.

It is possible to have a single statement span multiple lines when the line is too long to read on a screen. To do this, simply put a space and a backslash at the end of the line as explained earlier. Note that Python allows you to put multiple statements on a line by separating each statement with a semicolon:
>>> x = 1; y = 2

Leave a Reply

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