tutorial introduction the while statement tests the conditional expression that immediately follows if the tested statement is truethe body of the while statement executes the condition is then retested and the body executed again until the condition becomes false because the body of the loop is denoted by indentationthe three statements following while in listing execute on each iteration python doesn' specify the amount of required indentationas long as it' consistent within block howeverit is most common (and generally recommendedto use four spaces per indentation level one problem with the program in listing is that the output isn' very pretty to make it betteryou could right-align the columns and limit the precision of principal to two digits there are several ways to achieve this formatting the most widely used approach is to use the string formatting operator (%like thisprint "% % (yearprincipalprint("% % (yearprincipal)python now the output of the program looks like this format strings contain ordinary text and special formatting-character sequences such as "% ""% "and "%fthese sequences specify the formatting of particular type of data such as an integerstringor floating-point numberrespectively the specialcharacter sequences can also contain modifiers that specify width and precision for example"% dformats an integer right-aligned in column of width and "% fformats floating-point number so that only two digits appear after the decimal point the behavior of format strings is almost identical to the printf(function and is described in detail in "operators and expressions more modern approach to string formatting is to format each part individually using the format(function for exampleprint format(year," "),format(principal," "print(format(year," "),format(principal," ")python format(uses format specifiers that are similar to those used with the traditional string formatting operator (%for example" dformats an integer right-aligned in column of width and " fformats float-point number to have two digits of accuracy strings also have format(method that can be used to format many values at once for exampleprint "{ : { : }format(year,principalprint("{ : { : }format(year,principal)python in this examplethe number before the colon in "{ : }and "{ : }refers to the associated argument passed to the format(method and the part after the colon is the format specifier lib fl ff