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 Nested if Statements With Example

Below is the flow chart of python if statement.

Python if Statement Flowchart

Python-if-Statement-Flowchart

Example of Python if Statement

When the above program executes the following result will display.

Recommended:  First Program Hello World In Python Programming Language

In the above example of if statement in Python programming language we see that:

Recommended:  Introduction And Features Of Python Programming Language

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.

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.

This Post Has 2 Comments

  1. Great Job Sir.

    1. Thank You!

Leave a Reply

Close Menu