Python
Python
On
CONDITIONAL STATEMENT
SHRI RAMSWAROOP MEMORIAL
COLLEGE OF ENGINEERING AND
MANGEMENT
PRESENTED BY: PRESENTED TO:
AMARJEET IBM TRAINER
SUDHANSHU CHAUDHARY Mr.Manab Das
SACHIN PATEL
PANKAJ KUMAR
JAYPAL CHAUDHARY
OUTLINE
Introduction
If Statement
If-else Statement
If-elif-else
Statemement
Nested If
INTRODUCTION
Conditional statements in Python allow you to
control the flow of your program based on
certain conditions or criteria. They are essential
for making decisions in your code and executing
different blocks of code depending on whether a
condition is true or false.
If Statement
It is used to execute a block of code if a
specifie condition is true. If the condition is
false, the block of code is skipped.
Syntax:-
If <expression>:
<statement>
Algorithm
If-else
statement
The if-else statement executes a
block of code if a specified condition
is true. If the condition is false, then
else block of code are executed.
Syntax:-
if <exprression>:
<statement> <statement>
else:
<statement> <statement>
Algorithem
If-elif-else Statemement
The if-elif-else statement in python is a
control flow construct that allow you to
create a sequence of conditions and
execute different blocks of code based on
the evaluation of these conditions.it is
often used for decision-making in your
programs. if <expression>:
<statement(s)>
Syntax:- elif <expression>:
<statement(s)>
elif <expression>:
<statement(s)>
..
..
else<statement(s)>
Algorithem
NESTED IF
You can have if statements
inside if statements, this is
called nested if statements.
Syntax:-
if (condition1): # Executes when
condition1 is true if
(condition2): # Executes when
Ex.
condition2 is true #
x = 41
if Block is end here # if Block if x > 10:
is end here print("Above ten,")
if x > 20:
print("and also above 20!")
else:
print("but not above 20.")
CONCLUSION
• Write a clear and well-structured conditional
statement with meaningful condition names
• Avoid nested conditional statements when possible
to keep code readble
• Comment complex or critical conditions to improve
code maintainability.
• In conclusion,conditional statement are a crucial part
of programming that enable you to create dynamic
and decision-driven code,By using if,elif and else
constructs,you can control the flow of your program
and handle different scenarios based on
conditions,making your code more versatile and
responsive to real-world situations.
THANKU YOU
ALL
SRMCEM
IBM
TRAINER