Categories

Dec 12, 2019 in Python

Q: Python loops

1 Answer

Dec 12, 2019

The flow of the programs written in any programming language is sequential by default. Sometimes we may need to alter the flow of the program. The execution of a specific code may need to be repeated several numbers of times.

For this purpose, The programming languages provide various types of loops which are capable of repeating some specific code several numbers of times. Consider the following diagram to understand the working of a loop statement.

Python Loops

Why we use loops in python?

The looping simplifies the complex problems into the easy ones. It enables us to alter the flow of the program so that instead of writing the same code again and again, we can repeat the same code for a finite number of times. For example, if we need to print the first 10 natural numbers then, instead of using the print statement 10 times, we can print inside a loop which runs up to 10 iterations.

Click here to read more about Python
Click here to read more about Insurance

Related questions

Madanswer
Aug 30 in Python
Aug 30 in Python
Aug 29 in Python
...