SlideShare a Scribd company logo
ADVANCED PYTHON
PROGRAMMING
Lec: CSDS042
Lab: CSDS041L
Prof. Percival A. Fernandez
Module 2-Review of Python Decision making and Loops.pdf
• Decision making is anticipation of conditions occurring while execution of the
program and specifying actions taken according to the conditions.
• Decision structures evaluate multiple expressions which produce TRUE or FALSE as
outcome.
• Decision-making statements in programming languages decide the direction(Control
Flow) of the flow of program execution.
• Python programming language assumes any non-zero and non-null values as TRUE,
and if it is either zero or null, then it is assumed as FALSE value.
Python - Decision Making
Prof. Percival A. Fernandez
Types of Control Flow in Python
In Python programming language,
the type of control flow statements are as follows:
1.The if statement
2.The if-else statement
3.The nested-if statement
4.The if-elif-else ladder
Prof. Percival A. Fernandez
Python - Decision Making
Python programming language provides following types of decision making
statements
Prof. Percival A. Fernandez
Python - Decision Making
❖ if statement
The if statement is the most simple decision-making statement. It is used to decide
whether a certain statement or block of statements will be executed or not.
Syntax:
Prof. Percival A. Fernandez
Python - Decision Making
❖ if statement
• Here, the condition after evaluation will be either true or false. if the statement
accepts boolean values
• – if the value is true then it will execute the block of statements below it
otherwise not.
• As we know, python uses indentation to identify a block. So the block under an if
statement will be identified as shown in the below example:
Prof. Percival A. Fernandez
Python - Decision Making
Prof. Percival A. Fernandez
Python - Decision Making
❖ if statement - Flowchart of Python if statement
Prof. Percival A. Fernandez
Python - Decision Making
❖ if statement - Example
Prof. Percival A. Fernandez
Python - Decision Making
❖ if-else statement
• The if statement alone tells us that if a condition is true it will execute a block of
statements and if the condition is false it won’t.
• But if we want to do something else if the condition is false, we can use
the else statement with if statement to execute a block of code when the if condition
is false.
Syntax:
Prof. Percival A. Fernandez
Python - Decision Making
Python - Decision Making
❖ if-else statement - Flowchart of Python if statement
Prof. Percival A. Fernandez
❖ if-else statement - Example
Prof. Percival A. Fernandez
Python - Decision Making
❖ nested-if statement
• A nested if is an if statement that is the target of another if statement.
• Nested if statements mean an if statement inside another if statement.
• Yes, Python allows us to nest if statements within if statements. i.e, we can
place an if statement inside another if statement.
Syntax:
Prof. Percival A. Fernandez
Python - Decision Making
❖ nested-if statement - Flowchart of Python Nested if Statement
Prof. Percival A. Fernandez
Python - Decision Making
❖ nested-if statement –
❖ Flowchart of Python
❖ Nested if Statement
Prof. Percival A. Fernandez
Python - Decision Making
❖ nested-if statement - Example
Prof. Percival A. Fernandez
Python - Decision Making
❖ if-elif-else ladder
• Here, a user can decide among multiple options. The if
statements are executed from the top down. As soon as
one of the conditions controlling the if is true, the
statement associated with that if is executed, and the
rest of the ladder is bypassed.
• If none of the conditions is true, then the final else
statement will be executed.
Syntax:
Prof. Percival A. Fernandez
Python - Decision Making
❖ if-elif-else ladder –
❖ Flowchart of Python
❖ if-elif-else ladder
Prof. Percival A. Fernandez
Python - Decision Making
❖ if-elif-else ladder –
❖ Flowchart of Python if-elif-else ladder
Prof. Percival A. Fernandez
Python - Decision Making
❖ if-elif-else ladder - Example
Prof. Percival A. Fernandez
Python - Decision Making

More Related Content

PDF
Python Programming Part 3.pdf
PDF
W4-DecisionMaking.pdf. python document. CS
PPTX
RaspberryPi & Python Workshop Day - 02.pptx
PDF
basic of desicion control statement in python
PPTX
FLOW OF CONTROL-INTRO PYTHON
PDF
Python decision making
PDF
if statements in Python -A lecture class
PDF
Unit 1- Part-2-Control and Loop Statements.pdf
Python Programming Part 3.pdf
W4-DecisionMaking.pdf. python document. CS
RaspberryPi & Python Workshop Day - 02.pptx
basic of desicion control statement in python
FLOW OF CONTROL-INTRO PYTHON
Python decision making
if statements in Python -A lecture class
Unit 1- Part-2-Control and Loop Statements.pdf

Similar to Module 2-Review of Python Decision making and Loops.pdf (20)

PPT
Python Programming Unit II Control Statements.ppt
PPTX
pds first unit module 2 MODULE FOR ppt.pptx
PDF
E-Notes_3721_Content_Document_20250107032537PM.pdf
PPTX
Programming in python - Week 4
PPTX
conditional statement in python day 5.pptx
PPTX
Understanding-Conditional-Blocks-if-else-Nested-If-and-Loops.pptx
PPTX
Python4HPC.pptx
PPTX
industry coding practice unit-2 ppt.pptx
PPTX
Python Programming | JNTUK | UNIT 2 | Lecture 6 & 7 | Conditional & Control S...
PPTX
ControlStructures.pptx5t54t54444444444444444
PPTX
PRESENTATION.pptx
PPTX
Basic if and if else statements in Python
PPT
Decision Structures and Boolean Logic
PDF
Python Decision Making And Loops.pdf
PPTX
Lecture on Fundamentals of Python Programming-2
PPTX
Python Flow Control & use of functions.pptx
PDF
Python unit 2 M.sc cs
PPTX
2-Conditional Statements, decision making (3).pptx
PPTX
Introduction-to-Conditional-Statements-in-Python.pptx
PPTX
Conditionals
Python Programming Unit II Control Statements.ppt
pds first unit module 2 MODULE FOR ppt.pptx
E-Notes_3721_Content_Document_20250107032537PM.pdf
Programming in python - Week 4
conditional statement in python day 5.pptx
Understanding-Conditional-Blocks-if-else-Nested-If-and-Loops.pptx
Python4HPC.pptx
industry coding practice unit-2 ppt.pptx
Python Programming | JNTUK | UNIT 2 | Lecture 6 & 7 | Conditional & Control S...
ControlStructures.pptx5t54t54444444444444444
PRESENTATION.pptx
Basic if and if else statements in Python
Decision Structures and Boolean Logic
Python Decision Making And Loops.pdf
Lecture on Fundamentals of Python Programming-2
Python Flow Control & use of functions.pptx
Python unit 2 M.sc cs
2-Conditional Statements, decision making (3).pptx
Introduction-to-Conditional-Statements-in-Python.pptx
Conditionals
Ad

More from percivalfernandez2 (9)

PDF
Module 1 Review of Python Basics An Introduction
PPTX
Wk_10_Scanner and BufferedReader Class in Java.pptx
PPTX
Module 3 - Software Classification.pptx
PPTX
Data Analytics.pptx
PPTX
Python Programming Part 8 - MYSQL.pptx
PDF
Python Programming Part 1.pdf
PPTX
Wk8_Expansion and External Input and Output Devices.pptx
PDF
Advance C# Programming Part 1.pdf
PDF
Python Programming Part 1.pdf
Module 1 Review of Python Basics An Introduction
Wk_10_Scanner and BufferedReader Class in Java.pptx
Module 3 - Software Classification.pptx
Data Analytics.pptx
Python Programming Part 8 - MYSQL.pptx
Python Programming Part 1.pdf
Wk8_Expansion and External Input and Output Devices.pptx
Advance C# Programming Part 1.pdf
Python Programming Part 1.pdf
Ad

Recently uploaded (20)

PDF
01-Introduction-to-Information-Management.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Institutional Correction lecture only . . .
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
RMMM.pdf make it easy to upload and study
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Basic Mud Logging Guide for educational purpose
PDF
Complications of Minimal Access Surgery at WLH
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Lesson notes of climatology university.
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
01-Introduction-to-Information-Management.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Institutional Correction lecture only . . .
Microbial disease of the cardiovascular and lymphatic systems
Sports Quiz easy sports quiz sports quiz
Final Presentation General Medicine 03-08-2024.pptx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
O7-L3 Supply Chain Operations - ICLT Program
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
RMMM.pdf make it easy to upload and study
PPH.pptx obstetrics and gynecology in nursing
Anesthesia in Laparoscopic Surgery in India
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Basic Mud Logging Guide for educational purpose
Complications of Minimal Access Surgery at WLH
Computing-Curriculum for Schools in Ghana
Lesson notes of climatology university.
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Pharma ospi slides which help in ospi learning
O5-L3 Freight Transport Ops (International) V1.pdf

Module 2-Review of Python Decision making and Loops.pdf

  • 1. ADVANCED PYTHON PROGRAMMING Lec: CSDS042 Lab: CSDS041L Prof. Percival A. Fernandez
  • 3. • Decision making is anticipation of conditions occurring while execution of the program and specifying actions taken according to the conditions. • Decision structures evaluate multiple expressions which produce TRUE or FALSE as outcome. • Decision-making statements in programming languages decide the direction(Control Flow) of the flow of program execution. • Python programming language assumes any non-zero and non-null values as TRUE, and if it is either zero or null, then it is assumed as FALSE value. Python - Decision Making Prof. Percival A. Fernandez
  • 4. Types of Control Flow in Python In Python programming language, the type of control flow statements are as follows: 1.The if statement 2.The if-else statement 3.The nested-if statement 4.The if-elif-else ladder Prof. Percival A. Fernandez Python - Decision Making
  • 5. Python programming language provides following types of decision making statements Prof. Percival A. Fernandez Python - Decision Making
  • 6. ❖ if statement The if statement is the most simple decision-making statement. It is used to decide whether a certain statement or block of statements will be executed or not. Syntax: Prof. Percival A. Fernandez Python - Decision Making
  • 7. ❖ if statement • Here, the condition after evaluation will be either true or false. if the statement accepts boolean values • – if the value is true then it will execute the block of statements below it otherwise not. • As we know, python uses indentation to identify a block. So the block under an if statement will be identified as shown in the below example: Prof. Percival A. Fernandez Python - Decision Making
  • 8. Prof. Percival A. Fernandez Python - Decision Making
  • 9. ❖ if statement - Flowchart of Python if statement Prof. Percival A. Fernandez Python - Decision Making
  • 10. ❖ if statement - Example Prof. Percival A. Fernandez Python - Decision Making
  • 11. ❖ if-else statement • The if statement alone tells us that if a condition is true it will execute a block of statements and if the condition is false it won’t. • But if we want to do something else if the condition is false, we can use the else statement with if statement to execute a block of code when the if condition is false. Syntax: Prof. Percival A. Fernandez Python - Decision Making
  • 12. Python - Decision Making ❖ if-else statement - Flowchart of Python if statement Prof. Percival A. Fernandez
  • 13. ❖ if-else statement - Example Prof. Percival A. Fernandez Python - Decision Making
  • 14. ❖ nested-if statement • A nested if is an if statement that is the target of another if statement. • Nested if statements mean an if statement inside another if statement. • Yes, Python allows us to nest if statements within if statements. i.e, we can place an if statement inside another if statement. Syntax: Prof. Percival A. Fernandez Python - Decision Making
  • 15. ❖ nested-if statement - Flowchart of Python Nested if Statement Prof. Percival A. Fernandez Python - Decision Making
  • 16. ❖ nested-if statement – ❖ Flowchart of Python ❖ Nested if Statement Prof. Percival A. Fernandez Python - Decision Making
  • 17. ❖ nested-if statement - Example Prof. Percival A. Fernandez Python - Decision Making
  • 18. ❖ if-elif-else ladder • Here, a user can decide among multiple options. The if statements are executed from the top down. As soon as one of the conditions controlling the if is true, the statement associated with that if is executed, and the rest of the ladder is bypassed. • If none of the conditions is true, then the final else statement will be executed. Syntax: Prof. Percival A. Fernandez Python - Decision Making
  • 19. ❖ if-elif-else ladder – ❖ Flowchart of Python ❖ if-elif-else ladder Prof. Percival A. Fernandez Python - Decision Making
  • 20. ❖ if-elif-else ladder – ❖ Flowchart of Python if-elif-else ladder Prof. Percival A. Fernandez Python - Decision Making
  • 21. ❖ if-elif-else ladder - Example Prof. Percival A. Fernandez Python - Decision Making