SlideShare a Scribd company logo
1 of 14
In programming and scripting languages,
conditional statements or conditional
constructs are used to perform different
computations or actions depending on
whether a condition evaluates to true or
false.
Types of Conditional Statement
if
Statement
elif
Statement
Nested
If else
Statement
Python if statement is one of the most
commonly used conditional statements
in programming languages. It decides
whether certain statements need to be
executed or not. It checks for a given
condition, if the condition is true, then
the set of code present inside the ” if ”
block will be executed otherwise not.
The if condition evaluates a Boolean
expression and executes the block of
code only when the Boolean
expression becomes TRUE.
Syntax
If ( EXPRESSION == TRUE ):
Block of code
else:
Block of code
Example
num = 2
if (num < 10):
print(“Num is smaller than 10”)
print(“Yes, this condition is true ”)
“elif” statement is used
to check multiple
conditions only if the
given condition is false.
It’s similar to an “if-else”
statement and the only
difference is that in “else”
we will not check the
condition but in “elif” we
will check the condition.
“elif” statements are
similar to “if-else”
statements but “elif”
statements evaluate
multiple conditions.
if (condition):
#Set of statement to
execute if condition is
true
elif (condition):
#Set of statements to
be executed when if
condition is false and elif
condition is true
else:
#Set of statement to be
executed when both if
and elif conditions are
false
Syntax:
num = 10
if (num == 0):
print(“Number is Zero”)
elif (num > 5):
print(“Number is greater than 5”)
else:
print(“Number is smaller than 5”)
Example
Output
Number is
greater than 5
Nested “if-else” statements
mean that an “if” statement
or “if-else” statement is
present inside another if or
if-else block. Python
provides this feature as well,
this in turn will help us to
check multiple conditions in
a given program.
Syntax:
if (condition):
#Set of statement to
execute if condition is true
elif (condition):
#Set of statements
to be executed when if
condition is false and elif
condition is true
else:
#Set of statement to be
executed when both if and
elif conditions are false
Example
For more presentation
contact us on
raginijain0208@gmail.com
Conditionalstatement

More Related Content

What's hot

Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAChapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAMaulik Borsaniya
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming KrishnaMildain
 
Python Exception Handling
Python Exception HandlingPython Exception Handling
Python Exception HandlingMegha V
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonPriyankaC44
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONvikram mahendra
 
Types of Statements in Python Programming Language
Types of Statements in Python Programming LanguageTypes of Statements in Python Programming Language
Types of Statements in Python Programming LanguageExplore Skilled
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide shareDevashish Kumar
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Pedro Rodrigues
 
Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019Samir Mohanty
 
Python Decision Making
Python Decision MakingPython Decision Making
Python Decision MakingSoba Arjun
 
Introduction To Python
Introduction To PythonIntroduction To Python
Introduction To PythonVanessa Rene
 
Control Structures in Python
Control Structures in PythonControl Structures in Python
Control Structures in PythonSumit Satam
 
File handling in Python
File handling in PythonFile handling in Python
File handling in PythonMegha V
 

What's hot (20)

Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAChapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming
 
Python Exception Handling
Python Exception HandlingPython Exception Handling
Python Exception Handling
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in Python
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHON
 
Types of Statements in Python Programming Language
Types of Statements in Python Programming LanguageTypes of Statements in Python Programming Language
Types of Statements in Python Programming Language
 
Python for loop
Python for loopPython for loop
Python for loop
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)
 
Python programming
Python  programmingPython  programming
Python programming
 
Python Control structures
Python Control structuresPython Control structures
Python Control structures
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019
 
Python Decision Making
Python Decision MakingPython Decision Making
Python Decision Making
 
Introduction To Python
Introduction To PythonIntroduction To Python
Introduction To Python
 
Control Structures in Python
Control Structures in PythonControl Structures in Python
Control Structures in Python
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
 
Python
PythonPython
Python
 

Similar to Conditionalstatement

05 Conditional statements
05 Conditional statements05 Conditional statements
05 Conditional statementsmaznabili
 
conditional statements.docx
conditional statements.docxconditional statements.docx
conditional statements.docxssuser2e84e4
 
Python decision making part4
Python decision making part4Python decision making part4
Python decision making part4Vishal Dutt
 
W4-DecisionMaking.pdf. python document. CS
W4-DecisionMaking.pdf. python document. CSW4-DecisionMaking.pdf. python document. CS
W4-DecisionMaking.pdf. python document. CSMalikaKhan21
 
BSc. III Unit iii VB.NET
BSc. III Unit iii VB.NETBSc. III Unit iii VB.NET
BSc. III Unit iii VB.NETUjwala Junghare
 
Unit IV Array in VB.Net.pptx
Unit IV Array in VB.Net.pptxUnit IV Array in VB.Net.pptx
Unit IV Array in VB.Net.pptxUjwala Junghare
 
Licão 11 decision making - statement
Licão 11 decision making - statementLicão 11 decision making - statement
Licão 11 decision making - statementAcácio Oliveira
 
Control satkcher ppt
Control satkcher pptControl satkcher ppt
Control satkcher ppt6336Zeelvora
 
controlstatementspy.docx
controlstatementspy.docxcontrolstatementspy.docx
controlstatementspy.docxmanohar25689
 
Decision statements
Decision statementsDecision statements
Decision statementsJaya Kumari
 
Cse lecture-6-c control statement
Cse lecture-6-c control statementCse lecture-6-c control statement
Cse lecture-6-c control statementFarshidKhan
 
Shell Scripting Structured Commands
Shell Scripting Structured CommandsShell Scripting Structured Commands
Shell Scripting Structured CommandsDon Bosco BSIT
 
05. Conditional Statements
05. Conditional Statements05. Conditional Statements
05. Conditional StatementsIntro C# Book
 
control statements in python.pptx
control statements in python.pptxcontrol statements in python.pptx
control statements in python.pptxAnshu Varma
 

Similar to Conditionalstatement (20)

Python decision making
Python   decision makingPython   decision making
Python decision making
 
PRESENTATION.pptx
PRESENTATION.pptxPRESENTATION.pptx
PRESENTATION.pptx
 
05 Conditional statements
05 Conditional statements05 Conditional statements
05 Conditional statements
 
conditional statements.docx
conditional statements.docxconditional statements.docx
conditional statements.docx
 
Python decision making part4
Python decision making part4Python decision making part4
Python decision making part4
 
W4-DecisionMaking.pdf. python document. CS
W4-DecisionMaking.pdf. python document. CSW4-DecisionMaking.pdf. python document. CS
W4-DecisionMaking.pdf. python document. CS
 
BSc. III Unit iii VB.NET
BSc. III Unit iii VB.NETBSc. III Unit iii VB.NET
BSc. III Unit iii VB.NET
 
Unit IV Array in VB.Net.pptx
Unit IV Array in VB.Net.pptxUnit IV Array in VB.Net.pptx
Unit IV Array in VB.Net.pptx
 
Licão 11 decision making - statement
Licão 11 decision making - statementLicão 11 decision making - statement
Licão 11 decision making - statement
 
Control satkcher ppt
Control satkcher pptControl satkcher ppt
Control satkcher ppt
 
controlstatementspy.docx
controlstatementspy.docxcontrolstatementspy.docx
controlstatementspy.docx
 
loops.pdf
loops.pdfloops.pdf
loops.pdf
 
Data type
Data typeData type
Data type
 
Decision statements
Decision statementsDecision statements
Decision statements
 
Cse lecture-6-c control statement
Cse lecture-6-c control statementCse lecture-6-c control statement
Cse lecture-6-c control statement
 
Shell Scripting Structured Commands
Shell Scripting Structured CommandsShell Scripting Structured Commands
Shell Scripting Structured Commands
 
05. Conditional Statements
05. Conditional Statements05. Conditional Statements
05. Conditional Statements
 
Control_Statements.pptx
Control_Statements.pptxControl_Statements.pptx
Control_Statements.pptx
 
Unix shell scripts
Unix shell scriptsUnix shell scripts
Unix shell scripts
 
control statements in python.pptx
control statements in python.pptxcontrol statements in python.pptx
control statements in python.pptx
 

More from RaginiJain21

Jump statment in python
Jump statment in pythonJump statment in python
Jump statment in pythonRaginiJain21
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in pythonRaginiJain21
 
Python media library
Python media libraryPython media library
Python media libraryRaginiJain21
 
Basic python programs
Basic python programsBasic python programs
Basic python programsRaginiJain21
 
Python Libraries and Modules
Python Libraries and ModulesPython Libraries and Modules
Python Libraries and ModulesRaginiJain21
 
Data types in python
Data types in pythonData types in python
Data types in pythonRaginiJain21
 
Final presentation on python
Final presentation on pythonFinal presentation on python
Final presentation on pythonRaginiJain21
 

More from RaginiJain21 (8)

Jump statment in python
Jump statment in pythonJump statment in python
Jump statment in python
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in python
 
Python media library
Python media libraryPython media library
Python media library
 
Basic python programs
Basic python programsBasic python programs
Basic python programs
 
Python Libraries and Modules
Python Libraries and ModulesPython Libraries and Modules
Python Libraries and Modules
 
Data types in python
Data types in pythonData types in python
Data types in python
 
Python second ppt
Python second pptPython second ppt
Python second ppt
 
Final presentation on python
Final presentation on pythonFinal presentation on python
Final presentation on python
 

Recently uploaded

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 

Recently uploaded (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 

Conditionalstatement

  • 1.
  • 2. In programming and scripting languages, conditional statements or conditional constructs are used to perform different computations or actions depending on whether a condition evaluates to true or false.
  • 3. Types of Conditional Statement if Statement elif Statement Nested If else Statement
  • 4. Python if statement is one of the most commonly used conditional statements in programming languages. It decides whether certain statements need to be executed or not. It checks for a given condition, if the condition is true, then the set of code present inside the ” if ” block will be executed otherwise not. The if condition evaluates a Boolean expression and executes the block of code only when the Boolean expression becomes TRUE.
  • 5. Syntax If ( EXPRESSION == TRUE ): Block of code else: Block of code Example num = 2 if (num < 10): print(“Num is smaller than 10”) print(“Yes, this condition is true ”)
  • 6.
  • 7. “elif” statement is used to check multiple conditions only if the given condition is false. It’s similar to an “if-else” statement and the only difference is that in “else” we will not check the condition but in “elif” we will check the condition. “elif” statements are similar to “if-else” statements but “elif” statements evaluate multiple conditions. if (condition): #Set of statement to execute if condition is true elif (condition): #Set of statements to be executed when if condition is false and elif condition is true else: #Set of statement to be executed when both if and elif conditions are false Syntax:
  • 8. num = 10 if (num == 0): print(“Number is Zero”) elif (num > 5): print(“Number is greater than 5”) else: print(“Number is smaller than 5”) Example Output Number is greater than 5
  • 9.
  • 10. Nested “if-else” statements mean that an “if” statement or “if-else” statement is present inside another if or if-else block. Python provides this feature as well, this in turn will help us to check multiple conditions in a given program. Syntax: if (condition): #Set of statement to execute if condition is true elif (condition): #Set of statements to be executed when if condition is false and elif condition is true else: #Set of statement to be executed when both if and elif conditions are false
  • 12.
  • 13. For more presentation contact us on raginijain0208@gmail.com