def createlabeledwindow()window graphwin("investment growth chart" window setbackground("white"window setcoords(- ,- text(point(- ) 'draw(windowtext(point(- ) 'draw(windowtext(point(- ) 'draw(windowtext(point(- ) 'draw(windowtext(point(- )' 'draw(windowreturn window def drawbar(windowyearheight)bar rectangle(point(year )point(year+ height)bar setfill("green"bar setwidth( bar draw(windowdef main()print("this program plots the growth of year investment "principal eval(input("enter the initial principal")apr eval(input("enter the annualized interest rate")win createlabeledwindow(drawbar(win principalfor year in range( )principal principal ( aprdrawbar(winyearprincipalinput("press to quit "win close(main(although this version is longer than the previous versionexperienced programmers would find it much easier to understand as you get used to reading and writing functionsyou too will learn to appreciate the elegance of more modular code summary function is kind of subprogram programmers use functions to reduce code duplication and to help structure or modularize programs once function is definedit may be called