Exam 1_Spring 2011

Draw the output that would be displayed in the

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

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: range(12,17) f, s = s, f + s print("f =", f, " s=", s) (b) n=3 k=1 for c in range(5): n=c+k k=2*k 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) Circle(Point(50,50),40).draw(win) left right bottom top = = = = Point(10,50) Point(90,50) Point(50,10) Point(50,90) Line(left,right).draw(win) Line(bottom,top).draw(win) win.getMouse() win.close() main() 10. Write a complete program that, using a loop, asks the user for the number and cost of 10 items. The program should then print out the total cost. 7 Lehman College, CUNY CMP 230 Exam 1, Version 3 Spring 2011 1. Write Python code that prompts the user for the radius of a circle, and prints out the circumference of the circle. Useful formulas: circumf erence = 2 · π · radius 2. Trace the Python code below, i.e. indicate the state of t...
View Full Document

Ask a homework question - tutors are online