ITERATION (for AND while STATEMENT)
Suppose we wish to read and add 100 number. Using the method discussed so far, we will have to include 100 statement for reading and an equal number of statement for addition. If the number to be read and added were 10,000 instead of 100, we can well imagine the gigantic appearance of the program that would run into well over a hundred pages.Surely, we cannot think of doing that. The process of repetitive execution of a statement or a sequence of statements is called a loop.Using loops, we need to write only once the sequence of statement to be repeatedly executed.Execution of a sequence of statements in a loop is known as an iteration of the loop. The for statement in Python provides mechanism to keep count of the number of times a sequence of statements has been executed. Sometime, we say that the for statement loops over a sequence of statement and as such is also called for loop. At times, there may be a situation where the number of times, a sequence of statement has to be processed is not known in advance, we use a while loop.
1 Response to "ITERATION (for AND while STATEMENT)"
Excellent .. Amazing .. I’ll bookmark your blog and take the feeds also…I’m happy to find so many useful info here in the post, we need work out more techniques in this regard, thanks for sharing. buy shipping containers brisbane
Post a Comment