Categories: Python

Pass statement in Python language

Pass statement in Python language

In this tutorial, we will discuss the concept of pass statement in Python language.

In the Python programming language, the pass is a keyword(statements) that is used to indicate when nothing happens – the loops(for, while), function and class are empty.

Syntex

Syntex of the pass statements

pass

We can use pass statement to indicate a null block or it can be used to quickly add items that are in the unimplemented block in python.

 

Example 1

This for loop has no implementation
When we executed the above code, it produced the following results.

Display error message

Same for loop, there is no implementation but consists of pass statement. We can implement future.

When we executed the above code, it produced the following results.

No error but no output.

Example 2

This while loop has no implementation.
When we executed the above code, it produced the following results.
Display error message

When we executed the above code, it produced the following results.

The while loop, no implementation but consists of pass statement. we can implement future.

No error but no output

Example 3

This method has no implementation.
When we executed the above code, it produced the following results.

Display of error message

 

Same method, no implementation but consist pass statement, we can implement future

When we executed the above code, it produced the following results

No error but no output

Example 4
This class has no implementation.
When we executed the above code, it produced the following results

Display error message

Same class, no implementation but consist pass statement, we can implement future

When we executed the above code, it produced the following results

No error but no output

Some example programs with pass

Program 1

Example

When we executed the above program, it produced the following results

number is:1
number is:2
number is:3
number is:4
number is:5
number is:6
number is:7
number is:8
number is:9
number is:10
Exit from loop

Program 2

Example

When we executed the above program, it produced the following results

Karmehavannan

Recent Posts

Multiply two numbers in Java using scanner| 5 different ways

Multiply two numbers in Java using scanner| 5 different ways In this article, we will…

3 months ago

5 different ways to Divide two numbers in Java using scanner

5 Different ways to Divide two numbers in Java using scanner In this article, we…

3 months ago

Learn 8 Ways to Subtract Two Numbers Using Methods in Java

Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…

4 months ago

10 ways to subtract two numbers in Java

10 ways to subtract two numbers in Java In this article, we will discuss the…

4 months ago

Java Code Examples – Multiply Two Numbers in 5 Easy Ways

Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…

4 months ago

How to Divide two numbers in Java| 5 different ways

How to Divide two numbers in Java| 5 different ways In this article, we will…

4 months ago

This website uses cookies.