Exam 1_Spring 2011

The program then draws the axis aligned rectangle for

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: on graphics based program that requires the user to click on two points in its window. The program then draws the axis aligned rectangle for which those two points are in opposing corners along with both diagonals of this rectangle. 4 8. Trace the following Python code, i.e. indicate the state of the variables as they change and what output is printed to the screen: (a) f=5 s=8 for i in range(2,7) f, s = s, f + s print("f =", f, " s=", s) (b) n = 16 k=4 for c in range(5): n=n-c k=k+n print("n =", n, " k = ", k) 9. Draw the output that would be displayed in the program’s window if the following Python graphics based program were executed: from graphics import * def main(): win = GraphWin("Picture", 400, 400) win.setCoords(0,0,100,100) left right bottom top = = = = Point(10,50) Point(90,50) Point(50,10) Point(50,90) Line(left,top).draw(win) Line(top,right).draw(win) Line(right,bottom).draw(win) Line(bottom,left).draw(win) win.getMouse() win.close() main() 1...
View Full Document

This document was uploaded on 03/24/2014 for the course CMP 230 at Lehman College.

Ask a homework question - tutors are online