which adds the fractional value ten times to variable total since total has an initial value of mathematicallyit should equal after the loop terminates and the program should print the string "correctbut due to the imprecision of floating-point numberstotal contains value close to but not equal to and thus the program will print the string "not correctthe for loop the for statement in python is part of the built-in iterator mechanism used to traverse the individual items stored in sequence or collection the individual items in the given collection are assignedone at timeto the loop variable after each assignmentthe body of the loop is executed in which the loop variable is commonly used to perform some action on each item the loop body will be executed once for each item in the collection consider the following code segmentcount for letter in thestring if letter >"aand letter <"zcount + print"the string contained % uppercase characters count which traverses over the individual characters of the string "john smith"one at timeto count the number of uppercase letters contained in the string python' for statement is equivalent to the foreach constructs found in other languages thuswhen reading code containing for loopit' best to read the "forclause as "for eachconsider the loop in the previous code segmentwhich we would read as "for each letter in thestring do the followingwhere "do the followingrepresents the statements in the loop body python also provides the range(functionwhich can be used with the for statement to construct count-controlled loops consider the following code segmentwhich prints the range of integers from to one per linefor in range printi the range(function specifies sequence of integer values over which the for loop can traverse there are several forms of the range(function depending on the number of arguments supplied consider the following examplesthird argument indicates the increment amountdefault is for in range printi we can decrement through the range of values for in range - printi single argument will iterate through the rangestarting at for in range printi