Wednesday, June 17, 2020

Loop Control Statements in Python Programming



Hello dear readers! Welcome back to another section of my tutorial on Python. In this tutorial guide, we are going to be discussing about the Loop control statements in Python.

Normally, statements are executed sequentially: The first statement in a function is executed first and then followed by the second, and so on. There may be a situation when you need to execute a block of code several number of times.

Python provides different control structures that allows for more complicated execution paths.

A loop control statement allows you to execute a statement or group of statements multiple as many times as possible.

Flow Chart

The following diagram illustrates the flow chart of the loop control statement in Python -



Python provides the following types of loops to handle various looping requirements -

Sr.No.Loop Type & Description
1while loop
Repeats a statement or group of statements while a given condition is TRUE. It tests the condition before executing the loop body.
2for loop
Executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.
3nested loops
You can use one or more loop inside any another while, for or do..while loop.



Loop Control Statements

Loop control statements change the execution from its normal sequence. When execution leaves a scope, all automatic objects that were created in that scope gets destroyed.

Below are the control statements supported by Python -

Sr.No.Control Statement & Description
1break statement
Terminates the loop statement and transfers execution to the statement immediately following the loop.
2continue statement
Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.
3pass statement
The pass statement in Python is used when a statement is required syntactically but you do not want any command or code to execute.

RECOMMENDED POST: Python Operators

Alright guys! This is where we are rounding up for this tutorial. In my next tutorial, we will be discussing about the Python While Loops.

Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.
Share:

0 comments:

Post a Comment

Hello dear readers! Please kindly try your best to make sure your comments comply with our comment policy guidelines. You can visit our comment policy page to view these guidelines which are clearly stated. Thank you.