The document discusses different types of control structures in Python 3 including sequential, selection, and repetition structures. Selection structures include if, if-else, and if-elif-else statements which allow for branching based on conditions. Repetition structures include while and for loops, with while loops executing statements repeatedly until a condition is false and for loops iterating over a sequence. Do-while statements are also mentioned.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
28 views12 pages
Control Structures Python 3
The document discusses different types of control structures in Python 3 including sequential, selection, and repetition structures. Selection structures include if, if-else, and if-elif-else statements which allow for branching based on conditions. Repetition structures include while and for loops, with while loops executing statements repeatedly until a condition is false and for loops iterating over a sequence. Do-while statements are also mentioned.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12
CONTROL
STRUCTURES IN PYTHON 3 Sequential control Default mode.
Sequential execution of code statements ( one line after another),
like following a sequence of instructions Sequential control Selection control Use for decisions, branching. Choosing between 2 or more alternative paths.
CONDITION
True False Types of Selection control Selection statement: If statement
-The “if statement” is the simplest of the selection control
Types of Selection control Selection statement: If – else statement
-It consist of an if statement that execute a block of statement
whether it is true or false. Types of Selection control Selection statement: If - elif - else statement
-It consist of 2 or more if statement
Repetition - Causes a statement or set of statements to execute repeatedly
- The program execute a statement repeatedly until it reach the
set condition.
- Repetition statements fall into two general categories; while
loops and for loops. Although it is possible to write a loop as a while loop (or every loop as a for loop). This is not good idea While statement The Boolean expression (condition) in this example is: x <5 The expression has a value of true or false (1 or 0) If the condition is true, the intended statements are executed, otherwise, the statements are skipped. For statement For loop using range() For val in sequence: Body of for: Do-while statement