DA2001 - Python
Programming
H. M. Samadhi Chathuranga Rathnayake
Flow Control Structures
• Sequential Execution:
• The default flow of execution where statements are executed one after another in the order they
appear.
• Conditional Statements (Decision Making):
• Used to execute different blocks of code based on conditions.
• Looping Structures (Iteration):
• Used to repeat a block of code multiple times.
• Jump Statements (Control Flow Alteration):
• Used to change the normal sequence of execution.
Conditions and Branching
if Criteria:
Do
something
if
Criteria:
Do
something
else:
Do
something
if Criteria:
Do
something
elif Criteria:
Do
something
elif Criteria:
Do
something
else:
Do
For Loops
for iteration
in Array:
Do
something
For Loops
• Break keyword breaks the entire loop when a condition is satisfied.
• Continue keyword skips the iteration when a condition is satisfied.
While Loops
Python Functions
• Python functions are repeated blocks which will be used in several places in a program.
• Python functions can be created with arguments or without arguments.
• Python functions can be created with return values or without return values.

Lecture 03 of python programming - data nalaytics.pdf

  • 1.
    DA2001 - Python Programming H.M. Samadhi Chathuranga Rathnayake
  • 2.
    Flow Control Structures •Sequential Execution: • The default flow of execution where statements are executed one after another in the order they appear. • Conditional Statements (Decision Making): • Used to execute different blocks of code based on conditions. • Looping Structures (Iteration): • Used to repeat a block of code multiple times. • Jump Statements (Control Flow Alteration): • Used to change the normal sequence of execution.
  • 3.
    Conditions and Branching ifCriteria: Do something if Criteria: Do something else: Do something if Criteria: Do something elif Criteria: Do something elif Criteria: Do something else: Do
  • 4.
    For Loops for iteration inArray: Do something
  • 5.
    For Loops • Breakkeyword breaks the entire loop when a condition is satisfied. • Continue keyword skips the iteration when a condition is satisfied.
  • 6.
  • 7.
    Python Functions • Pythonfunctions are repeated blocks which will be used in several places in a program. • Python functions can be created with arguments or without arguments. • Python functions can be created with return values or without return values.