Flow control in Python
In this article, I will be discussing flow control in the python language. as an overview, I will be discussing IF, ELSE condition ELIF conditions, and loops (for, while loops).
If, Else and Elif conditions
If, Else Condition
Generally in if conditions we define a condition under certain terms to happen if the certain condition is not met the else part comes to action where the else part occurs.
Elif Condition
In Elif condition, we define multiple conditions to execute so that if one condition is not met one of the other conditions will be executed.
Loops (while, for, continue, break, range)
while loop
With the while loop, we can execute a set of statements as long as a condition is true.
For loop
The for loop in Python is used to iterate over a sequence (list, tuple, string) or other iterable objects. I will discuss what is a list and tuple in another blog.
Continue keyword
The continue statement is used to skip the rest of the code inside a loop for the current iteration only. Loop does not terminate but continues on with the next iteration.
Break keyword
The break statement terminates the loop containing it. Control of the program flows to the statement immediately after the body of the loop. If the break statement is inside a nested loop (loop inside another loop), the break statement will terminate the innermost loop.
Range keyword
The range() function returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and ends at a specified number.
I hope that’s all for this article now. let’s discuss in another article about Lists, tuples, and Range. Until then cheers to all.!!!