loop loop loop loop loop largest the variable largest is best thought of as the "largest value we have seen so farbefore the loopwe set largest to the constant none none is special constant value which we can store in variable to mark the variable as "emptybefore the loop startsthe largest value we have seen so far is none since we have not yet seen any values while the loop is executingif largest is none then we take the first value we see as the largest so far you can see in the first iteration when the value of itervar is since largest is nonewe immediately set largest to be after the first iterationlargest is no longer noneso the second part of the compound logical expression that checks itervar largest triggers only when we see value that is larger than the "largest so farwhen we see new "even largervalue we take that new value for largest you can see in the program output that largest progresses from to to at the end of the loopwe have scanned all of the values and the variable largest now does contain the largest value in the list to compute the smallest numberthe code is very similar with one small changesmallest none print('before:'smallestfor itervar in [ ]if smallest is none or itervar smallestsmallest itervar print('loop:'itervarsmallestprint('smallest:'smallestagainsmallest is the "smallest so farbeforeduringand after the loop executes when the loop has completedsmallest contains the minimum value in the list again as in counting and summingthe built-in functions max(and min(make writing these exact loops unnecessary the following is simple version of the python built-in min(functiondef min(values)smallest none for value in valuesif smallest is none or value smallestsmallest value return smallest in the function version of the smallest codewe removed all of the print statements so as to be equivalent to the min function which is already built in to python