Home / Python / If Statement in Python Programming Language

If Statement in Python Programming Language

If Statement in Python Programming Language

The working and structure of if statement is almost the same in other programming languages. In Python programming language the if statement is a logical expression which is used to evaluate values and returns the results base on the specified results. You can see the demo below:

Now we will break down the above if statement.

The above if statement only executes if the test expression is True otherwise it won’t run.

Recommended:  Python Keywords And Identifiers

Below is the flow chart of python if statement.

Python if Statement Flowchart


Example of Python if Statement

When the above program executes the following result will display.
In the above example of if statement in Python programming language we see that:

Recommended:  Python Introduction : Features Of Python

In our above example, the variable number is equal to 10 which is greater than 0 so our test condition become True and code inside of if is executed.

But in the second case where -1 is not greater than 0 so our test condition is not meet the specified condition so it becomes False and the code inside of this if statement will be skipped.

Recommended:  Python First Program Hello World

About Jack Sparrow

Hay I am Admin Of This Website. I am very passionate about Computers and technology. This website is the result of my passion. I love to eliminate the barriers comes in the for seeking education. This website is the free source of learning about new technology and up to date knowledge.

Check Also


Decision Making Statements In Python Programming Language

Decision Making In Python Programming Language In this lesson, we will learn all about decision …


  1. Avatar

    Great Job Sir.

Leave a Reply

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