Conditional Statements in Python

Click to rate this post!
[Total: 0 Average: 0]

Conditional statements in python performs actions (or) computations that depends on a certain condition(true(or) false).

Python supports different types of control statements. So, let us discuss one by one in detailed.

If statement :

Python If is a statement (or) a group of statements executes when a particular condition satisfies.

Conditional Statements in Python

Syntax :

If (condition = true)


Ex: i=1


Print (“condition satisfies(true)”)

Would you like to know how people use python for Data Science

If else statement:

In the above statement, there is no logic to execute if the IF condition fails. So this python if –else statement satisfies the condition.

As said above IF block executes if the condition satisfies. Otherwise Else block executes.

Conditional Statements in Python

if(Condition =true)

Statement 1


Statement 2

Ex : i=1

If (i==1)

Print(Since i=1 true condition executes)


Print(Since I not equal to 1  false condition executes)

Nested if :

There are some situations, where an operation needs to satisfy several conditions. Then we use Nested if condition. This is also called the Multiple If statements.

Conditional Statements in Python

Syntax :
If(condition = true)

Statement 1


Statement 2

elif(condition =true)

statement 3


statement 4




Print(’10 is less than 100’)


Print(’10 equals to 20’)


Print(‘we cannot equate 10 with 20’)


Print(‘There is no true condition in the statements. So else block is executed’).

Since these concepts were common in many programming languages like C, JAVA .So I advice you to practice more code on this loop. Feel free to clarify the doubts at Software training institutes

Break statement

As like above, we cannot expect only one / two conditions. In some, there may be a 100 (or) even maybe a 1000 conditions. Moreover, there is only a need for one block of statements to execute if the condition satisfies. So in those cases, we uses break statement.

Conditional Statements in Python

If (condition 1 )

Statement 1


If(condition 1)

Statement 2



Statement 3

Ex :

 I = 20

If ( 1==10)

Print(‘I not equal to 20’)



Print(‘Condition satisfies’)



Print(‘No condition satisfies’)

Continue :

This is somewhat similar to the Break statement. Hence the condition satisfies it skip the current statement and forces to process the next iteration.

Since these were common in every programming languages like C, JAVA, So, I would like to leave the code for you as an exercise. And if  you were struck up anywhere python online training will guide you

to our newsletter

Drop Us A Query

Trending Courses
  • Microsoft Azure Architect Technologies(AZ-300) | ITGuru
    Microsoft Azure Architect Technologies(AZ-300)
  • Azure is a great Microsoft Cloud Computing platform in providing various cloud services through online. ITGuru Certified Azure Architect certification course gives you the practical knowledge on Azure Cloud platform through real-world use cases from live experts

  • ServiceNow Admin Training | ITGuru
    ServiceNow Admin Training
  • Getting knowledge of cloud platforms like ServiceNow is essential in today’s world for the smooth running of projects in cloud platform. Turn your dream to the reality of becoming the Certified ServiceNow Administrator through ServiceNow Administration online certification Course with practical examples by live industry experts through online at ITGuru with real-world use cases.

  • Workday Financials Training | ITGuru
    Workday Financials Training
  • knowing the basics on any platform like Workday is not enough to sustain the IT industry. Hence it is essential to go beyond on Workday basics like Workday Financials training which lets you know the application of Financials management in real -world use cases from ITGuru Live Experts in a practical way.

  • Workday Training
  • An organization is considered as the best one when it offers the best benefits to the employee. Moreover, the greater the employee benefits, the greater the contribution to the organization. ITGuru let you know the practical workday Human Resource Management(HRM) features with live examples by experts

  • Python Online Course | ITGuru
    Python Online Course
  • Turn your dream into reality by ITGuru live experts with real-world use cases through practical knowledge on python online course and become the certified associate in python programming and become a master in python programming

  • Python Programming | ITGuru
    Python Programming
  • Python is the trending programming language in the IT industry. Mastering in python programming gives you more value among the people in the IT industry. Hence start today to learn python programming online by live experts with real-time uses cases at ITGuru

100% Secure Payments. All major credit & debit cards accepted.

Call Now Button