  #### Top Courses #### Machine Learning with Python & Statistics 4 (4,001 Ratings) 220 Learners

More webinars

# Python 3 - Decision Making Shery Dsouza

4 months ago # Python 3 - Decision Making

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 Decision-Making Structure | insideaiml
• 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

## 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

### 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