World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITians, only for AI Learners.
Designed by IITians, only for AI Learners.
New to InsideAIML? Create an account
Employer? Create an account
Download our e-book of Introduction To Python
4.5 (1,292 Ratings)
559 Learners
Pallavi Dhotre
2 years ago
#example of Decision making statements in python
#if statement (single-alternative)
systemIsOn=True #Assume system is on
if systemIsOn==True: #checking the condition
print("Welcome") #condition is true then print the message
Welcome
#example of Decision making statements in python
#if-else statement (dual-alternative)
systemIsOn=input()
if systemIsOn==True: #checking the condition
print("Welcome") #condition is true then execute this part
else: #if the condition is false
print("Turn on your system") #execute this part
False
Turn on your system
#example of Decision making statements in python
#if-elif-else statement (multiple-alternative)
number=int(input("Enter the 3-digit number: "))
if number%100==0:
print("Divisible by 100")
elif number%50==0:
print("Divisible by 50")
elif number%20==0:
print("Divisible by 20")
elif number%10==0:
print("Divisible by 10")
else:
print("Try again")
Enter the 3-digit number: 200
Divisible by 100
#example of Decision making statements in python
#nested statement
number=int(input("Enter the 3-digit number: "))
if number%100==0:
print("Divisible by 100")
else:
if number%50==0:
print("Divisible by 50")
else:
print("Try again")
Enter the 3-digit number: 135
Try again