Control Flow in Python Directing the Execution Path
Control Flow in Python Directing the Execution Path
by Santusht
Conditional Statements: Mastering
Decision Making
If Elif Else
The if statement evaluates a The elif Melse ifN statement The else statement executes if
conditionA If true; it executes a checks another conditionA ItEs all preceding conditions are
block of codeA used when the initial if falseA It provides a default code
condition is falseA blockA
Looping Constructs:
Harnessing Repetitive
Tasks
For Loop
1 The for loop iterates over a sequence Mlist; tuple;
stringNA It executes a block of code for each itemA
While Loop
2 The while loop executes as long as a condition is
trueA Be careful to avoid infinite loopsA
Nested Loops
3 You can nest loops within each otherA This allows
for complex iteration patternsA