as you have seen beforewin close(closes the graphics window while our earlier text-based python programs have automatically terminated after the last line finishes executingthat is not true for programs that create new windowsthe graphics window must be explicitly closed the win close(is necessary we will generally want to prompt the user to finally close the graphics window because such sequence is so commoni have added another method for zelle' graphwin objectspromptcloseso the last four lines can be reduced to win promptclose(win getwidth()/ where the only specific data needed is the coordinates of the center of the prompt the modified program is in face py you can copy the form of this program for other simple programs that just draw picture the size and title on the window will changeas well as the specific graphical objectspositionsand colors something like the last line can be used to terminate the program warningif you write program with bugand the program bombs out while there is graphwin on the screena dead graphwin lingers the best way to clean things up is to make the shell window be the current window and select from the menu shell restart shell another simple drawing example is balloons py feel free to run it and look at the code in idle note that the steps for the creation of all three balloons are identicalexcept for the location of the center of each balloonso loop over list of the centers makes sense the next exampletriangle pyillustrates similar starting and ending code in addition it explicitly interacts with the user rather than the code specifying literal coordinates for all graphical objectsthe program remembers the points where the user clicked the mouse they are used as the vertices of triangle return to the directory window for the python examples in windows you may be able to double click on the icon for triangle py to run it or on macyou can run it using the python launcherrather than idle while running the programfollow the prompts in the graphics window and click with the mouse as requested after you have run the programyou can examine the program in idle or look below'''programtriangle py or triangle pyw (best name for windowsinteractive graphics program to draw trianglewith prompts in text object and feedback via mouse clicks ''from graphics import def main()win graphwin('draw triangle' win yup(right side up coordinates win setbackground('yellow'message text(point(win getwidth()/ )'click on three points'message settextcolor('red'message setstyle('italic'message setsize( message draw(winget and draw three vertices of triangle win getmouse( draw(winp win getmouse( draw(winp win getmouse( graphics