Decision Control Statements 1690351742158
Decision Control Statements 1690351742158
Statements
Example:
Example:
Example:
Example:
11
12
13
14
16
* 1 1 1
** 1 2 2 2 121
*** 1 23 3 33 12321
**** 1 234 4 444 123432
***** 1 2345 5 5555 1
1234543
21
© OXFORD UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED. 17
The Break Statement
The break statement is used to terminate the execution of the nearest enclosing loop in
which it appears. The break statement is widely used with for loop and while loop. When
compiler encounters a break statement, the control passes to the statement that follows
the loop in which the break statement appears.
Example:
18
19
20
Unlike C and C++, in Python you can have the else statement associated with a loop
statements. If the else statement is used with a for loop, the else statement is executed
when the loop has completed iterating. But when used with the while loop, the else
statement is executed when the condition becomes false.
Examples:
21