Looping in Python #part 1

 Looping in Python

Part -1
.......................REAL CODERz....................

......................................................................
Let's begin...
........................


Introduction ----------



What is python?
Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms, including structured, object-oriented and functional programming.

What is looping in python
Looping means repeating something over and over until a particular condition is satisfied. A for loop in Python is a control flow statement that is used to repeatedly execute a group of statements as long as the condition is satisfied.


...........................................................................



Till now all the statements are generally executed in a sequential manner. But at times, users need to change the order by repairing on the skipping the execution of a few statements subject to a given condition. At this time the flow of execution is altered by the use of Control Statements.

There are three ways in which a program can be executed - Sequential, Selection and Iteration (Loops)..

In Sequential construct the instructions are executed one after the other in the order they are written. For example, if you want a program to calculate the area of rectangle first enter the length and breadth of a rectangle then calculate its area and print the result.

In seletion constructed depending upon the condition of decision has to be taken. If the condition evaluates to true certain steps are to be excluded and if the condition evaluate to falls different set of statement are to be excluded. For example, if a number is completely divisible by 2 then it is an even number otherwise it is an odd number.


Loops


In a program there are situation when a using have to repeat one or more statement many times this repetition is carried out using loop in programming.

Let us understand the concept of a loop with the help of a real life example. Suppose your  mother gives you a bowl of a fruit salad. You do not eat up all the fruits salad at once. You first have the one spoon, then you have the second spoon and so on. This way you finished your salad after many rounds of eating up the spoon.

Let us analyse the above example of loop using programming.

Let the control variable be A. In this example we have taken the initial value of a as zero. When you eat the first spoon the value of a become one after the second spoon the value become a request to A + 1 and so on. This value will increase each time the process repeat. After incrementing, the control variable C, will be checked against the maximum number of repetition which is 10 round.

This process will continue until the value A become 10 full stop it means the loose will continue for 10 times and then it will terminate.

Loop statement allow us to execute a statement or group of statement multiple time. There are two types of loops in Python.
1- while loop
2- for loop

Comments

Post a Comment

Popular posts from this blog

Codes for making middle finger in python

Codes for drawing free fire logo in python