SlideShare a Scribd company logo
2
Most read
4
Most read
14
Most read
Conditionalstatement
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 ”)
Conditionalstatement
“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
Conditionalstatement
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
Conditionalstatement
For more presentation
contact us on
raginijain0208@gmail.com
Conditionalstatement

More Related Content

PPTX
Unit-I Introduction to Cloud Computing.pptx
PPTX
Looping statement in python
PDF
Python If Else | If Else Statement In Python | Edureka
PPTX
Conditional and control statement
PDF
Strings in python
PDF
Operators in python
PPTX
Conditional Statement in C Language
PPTX
unit testing and debugging
Unit-I Introduction to Cloud Computing.pptx
Looping statement in python
Python If Else | If Else Statement In Python | Edureka
Conditional and control statement
Strings in python
Operators in python
Conditional Statement in C Language
unit testing and debugging

What's hot (20)

PPTX
Methods in java
PPTX
python conditional statement.pptx
PPTX
Classes, objects in JAVA
PPTX
Exception handling in JAVA
PPTX
Python for loop
PPT
Control structure C++
PDF
Python programming : Control statements
PDF
Introduction to Python
PPTX
Functions in python slide share
PPTX
If else statement in c++
PPTX
Python Functions
PPT
Strings
PPTX
If statements in c programming
PDF
Arrays in Java
PPSX
Exception Handling
PPT
Basic concept of OOP's
PPTX
Functions in Python
PPTX
Unary operator overloading
PDF
Loops and conditional statements
Methods in java
python conditional statement.pptx
Classes, objects in JAVA
Exception handling in JAVA
Python for loop
Control structure C++
Python programming : Control statements
Introduction to Python
Functions in python slide share
If else statement in c++
Python Functions
Strings
If statements in c programming
Arrays in Java
Exception Handling
Basic concept of OOP's
Functions in Python
Unary operator overloading
Loops and conditional statements
Ad

Similar to Conditionalstatement (20)

PPTX
conditional statement in python day 5.pptx
PDF
Python decision making
PPTX
PRESENTATION.pptx
PPT
05 Conditional statements
DOCX
conditional statements.docx
PPTX
Python decision making part4
PPTX
FLOW OF CONTROL-INTRO PYTHON
PDF
W4-DecisionMaking.pdf. python document. CS
PPTX
control-structure.pptxcontrol-structure.pptx
PPTX
ControlStructures.pptx5t54t54444444444444444
PPTX
BSc. III Unit iii VB.NET
PPTX
Unit IV Array in VB.Net.pptx
PPTX
Licão 11 decision making - statement
PPTX
Control satkcher ppt
DOCX
controlstatementspy.docx
PDF
loops.pdf
PDF
Computer Programming 1 Computer programmingComputer programmingComputer progr...
PPTX
2-Conditional Statements, decision making (3).pptx
DOCX
Data type
PPTX
Decision statements
conditional statement in python day 5.pptx
Python decision making
PRESENTATION.pptx
05 Conditional statements
conditional statements.docx
Python decision making part4
FLOW OF CONTROL-INTRO PYTHON
W4-DecisionMaking.pdf. python document. CS
control-structure.pptxcontrol-structure.pptx
ControlStructures.pptx5t54t54444444444444444
BSc. III Unit iii VB.NET
Unit IV Array in VB.Net.pptx
Licão 11 decision making - statement
Control satkcher ppt
controlstatementspy.docx
loops.pdf
Computer Programming 1 Computer programmingComputer programmingComputer progr...
2-Conditional Statements, decision making (3).pptx
Data type
Decision statements
Ad

More from RaginiJain21 (7)

PPTX
Jump statment in python
PPTX
Python media library
PPTX
Basic python programs
PPTX
Python Libraries and Modules
PPTX
Data types in python
PPTX
Python second ppt
PPTX
Final presentation on python
Jump statment in python
Python media library
Basic python programs
Python Libraries and Modules
Data types in python
Python second ppt
Final presentation on python

Recently uploaded (20)

PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Basic Mud Logging Guide for educational purpose
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
RMMM.pdf make it easy to upload and study
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
human mycosis Human fungal infections are called human mycosis..pptx
Microbial disease of the cardiovascular and lymphatic systems
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Basic Mud Logging Guide for educational purpose
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
102 student loan defaulters named and shamed – Is someone you know on the list?
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Complications of Minimal Access Surgery at WLH
RMMM.pdf make it easy to upload and study
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Cell Structure & Organelles in detailed.
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
01-Introduction-to-Information-Management.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPH.pptx obstetrics and gynecology in nursing
Abdominal Access Techniques with Prof. Dr. R K Mishra
VCE English Exam - Section C Student Revision Booklet
Week 4 Term 3 Study Techniques revisited.pptx

Conditionalstatement

  • 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 ”)
  • 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
  • 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
  • 13. For more presentation contact us on raginijain0208@gmail.com