You are on page 1of 16

Flow of control-

conditional statement
Program Control Flow
• A program’s control flow is the order in which the
program’s code executes. A flow control statement
defines the flow of the execution of the program.
Control flow statement are required to alter the
flow of program execution based on the
conditions.
• It is classified into three categories.
2.Selection/
1.Sequence 3.looping
Decision
Sequence
•Sequential statement in the program are
executed in a sequential order or in a
linear fashion , one after another ,
without any jump. Statement 1

•example Statements are


Statement 2

executed in
sequence , one Statement 3
after another
Selection Condition
• These statement in a program are execute when the program
uses a condition to decide which set of statement is to be
executed b/w two alternative sets of statement.
• In conditional statement ‘if’ statements are used.

Here ,’body of if’ statement will be


execute if test condition evaluates
to true .
Looping
• These statement in a program are executed when a certain set
of statement need to be executed multiple time in a loop.
• Example
Here , as long as
condition was true loop
runs , as the condition
become false loop exit.
• Output
1
2
3
Decision

making

statement
Decision making
• Decision making statement are used to control the
flow of execution of a program depending upon
the condition.
• There four types of decision-making statements in
python: 1.If statement

2.If-else statement

3.if-elif ladder

4.Nested if-else statement


If-statement
• If statement simply states that something is true ,
python should perform the steps that follow and
dose nothing in case the condition
evaluates to false.
EXAMPEL:
•Illustrating the concept of ‘if’ statement.
If-else statement
• ‘if’ statement tells us that if a condition is true , it will execute a block of
statement and if the condition is false , it won’t . We can use the else statement
with if statement to execute a block of code when the condition is false.
• Syntax
EXAMPLE:
•Illustrating the concept if-else statement.
if-elif-else statement
• if-elif-else construct is used in the situations where a user can
decide among multiple options.As soon as one of the condition
controlling the ‘if’ is true, then statement /statements associated
with that are executed, and the rest of the
ladder is bypassed.
EXAMPLE:
• Illustrating the concept of ’if’ statement, accept the percentage of a
student and display the grade accordingly.
Nested if-else statement
• The nested if…else statement allows you to check for multiple test exprissions
and execute different codes for more than two conditions .We can have many
levels of nesting inside if…else statement.
THANK
YOU
Name : Mohammad Arhaan
Class : XI
Roll.no :46
Subject : Computer Science
Topic : Flow of control-
conditional statement

Disclaimer
created with the help of google and the picture are taken from google image.

You might also like