All Courses #### Top Courses #### Master's In Artificial Intelligence Job Guarantee Program 4.5 (1,292 Ratings) 559 Learners

#### How To Land a Job in Data Science? Feb 9th (7:00 PM) 182 Registered
More webinars

# Python 3 - Decision Making Shery Dsouza

a year ago • Introduction
• Python Decision-Making Structure
• Decision-making statements
1. if Statement
2. if-else statement

## Introduction

Decision-making is the conditional choice. The block of code is executed based on the condition. If the condition is not satisfied then the next condition is executed.
In Decision-making conditional expression produce "TRUE" or "FALSE" result. If the result is TRUE first statement is executed and if the result is FALSE second statement is executed.

## Python Decision-Making Structure • In decision-making zero or null values consider as FALSE and non-zero or non-null values consider as TRUE.
You can use one if or else if statement or use can use if-elif ladder .

Recommended blog for you : Python 3 - Lists

## Decision-making Statements

### 1. if Statement

It is a single-line and simple statement.
Example :
``````value = 1000
if ( value == 1000 ) :
print ("Value of expression is 1000")``````
Output :
``Value of expression is 1000``

### 2. if-else statement

The if-else statement checks the condition . If result is TRUE then execute if block otherwise execute else block.
Example :
``````no1 = 10
no2 = 50
if(no1 >= no2 ):
print(“ No 1 is greater than No 2”)
else:
print(“No 2 is greater than No 1”)``````
Output :
``No 2 is greater than No 1``

The elif statement check multiple conditions.It execute the condition if one of  the result is TRUE.
Example :
``````value1 = 10
value2 = 10

if value1 > value2:
print("value1 is greater")
elif value1 == value2:
print("both are equal")
else:
print("value2 is greater")``````
Output :
``both are equal``
Like the Blog, then Share it with your friends and colleagues to make this AI community stronger.