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

Share
Published by
Karmehavannan

Recent Posts

Subtract two numbers using method overriding

Subtract two numbers using method overriding   Program 1

1 month ago

PHP Star triangle Pattern program

PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…

1 month ago

Using function or method to Write temperature conversion : Fahrenheit into Celsius

Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…

1 year ago

Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user

Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…

1 year ago

Write temperature conversion program: Fahrenheit into Celsius

Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…

1 year ago

How to write a program to convert Fahrenheit into Celsius

How to write a program to convert Fahrenheit into Celsius In this article, we will…

1 year ago

This website uses cookies.