we notice that there is some overhead in function calls the impact of the overhead reduces quickly with the amount of computational work inside the function for loops many computations are repetitive by nature and programming languages have certain loop structures to deal with this here we will present what is referred to as for loop (another kind of loop is while loopto be presented afterwardsassume you want to calculate the square of each integer from to this could be done with the following two-line program for in [ ]print ** note the colon and indentation againwhat happens when python interprets your code herefirst of allthe word for is reserved word signalling to python that for loop is wanted python then sticks to the rules covering such constructions and understands thatin the present examplethe loop should run successive times ( iterations should be done)letting the variable take on the numbers in turn during each iterationthe statement inside the loop ( print ** is carried out after each iterationi is automatically (behind the sceneupdated when the last number is reachedthe last iteration is performed and the loop is finished when executedthe program will therefore print out and the variable is often referred to as loop indexand its name (here iis choice of the programmer note thathad there been several statements within the loopthey would all be executed with the same value of (before changed in the next iterationmake sure you understand how program execution flows hereit is important in pythoninteger values specified for the loop variable are often produced by the built-in function range the function range may be called in different waysthat either explicitlyor implicitlyspecify the startstop and step ( changeof the loop variable generallya call to range reads range(startstopstepthis call makes range return the integers from (and includingstartup to (but excluding!stopin steps of step note here that stop- is the last integer included with rangethe previous example would rather read for in range( )print ** by defaultif range is called with only two parametersthese are taken to be start and stopin which case step of is understood if only single parameter is used in the call to rangethis parameter is taken to be stop the default step of