Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 11

CONDITIONAL STATEMENTS

TYPES OF STATEMENTS
Statements are the instructions given to the
computer to perform any kind of action.
Types of statements:
• Empty Statement
• Simple or single statement
• Compound statement
Empty Statement
• The simplest statement is the empty statement
ie., a statement which does nothing.
• In Python an empty statement is pass
statement.
Format:
pass
• Wherever Python encounters a pass
statement,Python does nothing and moves to
next statement in the flow of control
SIMPLE STATEMENT
Any single executable statement is a simple
statement in Python.
For Example:
print(“welcome”)
COMPOUND STATEMENT
A Compound statement represents a group of statements
executed as a unit.
Format for Compound statement:
<Compound statement header>:
<indented body containing multiple simple and or
compound statements>
A compound statement has:
• a header line begins with a keyword and ends with colon
• a body consisting of one or more Python statements,each
indented line inside the header line.All statements in the
body are at the same level of indentation.
STATEMENT FLOW OF CONTROL
Statements may be executed sequentially,
selectively or iteratively.
SEQUENCE STATEMENTS:
• Every Python program begins with the first
statement of program.
• Each statement in turn is executed.
• When the final statement of the program is
executed,the program is done.
SELECTION STATEMENT
• The selection construct means the execution
of statement(s) depending upon a condition
test.
• If a condition evaluates to True,a set of
statements under that condition will be
executed otherwise different set of
statements will be executed.
ITERATION OR LOOPING STATEMENTS
• The iteration construct means repetition of set
of statements depending upon the condition
test.
• Till the time a condition is True (or False
depending upon the loop),a set of statements
are repeated again and again.
• As soon as the condition ,becomes False(or
True)the repetition stops.

You might also like