Professional Documents
Culture Documents
STRUCTURES
TOPIC OUTLINE
▪ Control Structures
▪ Sequential
▪ Alternative or Branching
✓if
✓if..else
✓if..elif..else
▪ Iterative or Looping
✓while
✓for
✓Nested loop
▪ Jumping Statements
✓break
✓continue
CONTROL STRUCTURES
▪ A program statement that causes a
jump of control from one part of the
program to another is
called control structure or control
statement.
SEQUENTIAL Statement
▪ A sequential statement is composed of a
sequence of statements which are
executed one after another. A code to
print your name, address and phone
number is an example of sequential
statement.
▪ Example
SEQUENTIAL Statement
EXAMPLE CODE: OUTPUT:
SEQUENTIAL Statement
EXAMPLE CODE: OUTPUT:
ALTERNATIVE/BRANCHING
▪ Often called decision making statement
▪ Decision making statement depends on the
condition block that needs to be executed or not
which is decided by condition.
▪ TYPES
▪ Simple if
▪ if..else
▪ Nested if..elif..else
2. Second execution
2. Second execution
ALTERNATIVE/BRANCHING
Nested if..elif..else
• When we need to construct a chain of if statement(s)
then ‘elif’ clause can be used instead of ‘else’.
▪ Syntax:
▪ TYPES
▪ while loop
▪ for loop
ITERATIVE or LOOPING
while loop
▪ can execute a set of statements as long as a
condition is true.
▪ Syntax:
▪ Where,
▪ start – refers to the initial value
▪ stop – refers to the final value
▪ step – refers to increment value, this is
optional part.
ITERATIVE or LOOPING
for loop (cont.)
▪ Example for range()
– range (1,30,1) - will start the range of
values from 1 and end at 29
– range (2,30,2) - will start the range of
values from 2 and end at 28
– range (30,3,-3) - will start the range of
values from 30 and end at 6
– range (20) - will consider this value 20 as
the end value(or upper limit) and starts
the range count from 0 to 19 (remember
always range() will work till stop -1 value
only)
ITERATIVE or LOOPING
for loop (cont.)
EXAMPLE CODE: OUTPUT: