Technology

Statements in Python

The order during which a program executes is understood as the program’s management flow. In Python artificial language, the management flow is regulated by conditional python statements, loops and functions career. In the article, we will go on to study all the Python statements that are utilized in Python’s artificial language.

Types of Python Statements

Below are Python Statements:-

  1. Return Statement
  2. Break Statement
  3. Continue Statement
  4. Pass Statement
  5. If Statement
  6. If-Else Statement
  7. Elif Statement

So it’s time to check all the on top of mentioned Python Statements in brief with the assistance of a general example.

Return Statement

The main function of Return Statement in Python is to finish the execution of the function and “returns” the result. The code which we write after the return statement are not executed. Return Statement s used when we want to execute the function with some value to be return. If the return statement is not with any expression (means it does not have anything except return), then NONE is returned back. Read about python remove last character from string with example

Example to Python Return statement

In the above code func1 gives the value of the return statement and provides us the output.

Break Statement

Break statements in python area unit accustomed terminate the present loop and resume execution at succeeding statement. the most operate of Break statement in python is function to bring the management out of the loop once beneath any external condition is triggered to the operate or loop. One will use Break Statement certain loop and whereas loop.

Let’s understand the Break Statement with below example

In the above code, the function stopped working after the Break Statement. When the variable reaches “a”  it executes the break statement and moves to the next iteration

Continue Statement

In Python, we have a tendency to use Continue Statement to skip the code that comes when the continue keyword and there’s an effect within the statement that is passed back to the beginning for succeeding iteration. the foremost practicality of Continue Statement is to come back the management at the start of the loop. We can use Continue Statement in both for loop and while loop.

Let’s check the example about the Continue statement

Related posts

Top Programming Languages AI Engineers Need to Grab in 2020

Alen Parker

Why Users Save More Videos Quickly Via A User-Friendly App?

Emart Spider Admin

The use of Wireless Tour Guide System in Worship Places

Emart Spider Admin