Lecture 4 - Control Flow
Lecture 4 - Control Flow
Chapter 4
Control Flow
CCS 218: Programming Fundamentals II
Chapter One: Getting Started with Python
Decision Control Statement
› Program execution is sequential and one way to alter the course of
execution is to use DECISION MAKING STATEMENTS
› Decision can be made on the basis of SUCCESS or FAILURE of some
logical condition (which are included in the program as Decision
Control Statement)
› Python supports the following decision making control statements:
• The if statement
• The if-else statement
• The Nested if-else statement
• The elif ladder statement
• The match –case statement.
CBE 312 - Data Structures and Algorithms Mr. David L. A. Abbas
Chapter One: Getting Started with Python
The if statement
› The if statement is used to execute/skip a block of statements on
the basis of truth or falsity of a condition.
› The condition to be checked is put inside the parenthesis which is
preceded by keyword if
› EXERCISE: Modify the above python code to display the minimum value
CBE 312 - Data Structures and Algorithms Mr. David L. A. Abbas
Chapter One: Getting Started with Python
Match Case Selection Structure
› Switch-case statement can be used to replace else-if ladder
construct. Its general syntax is as follows:
Iteration Control
(Looping)
To be continued
CBE 312 - Data Structures and Algorithms Mr. David L. A. Abbas