Exam 1_Spring 2011

Drawwin for n in range10 100 10 linepoint0n

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: for n in range(10, 100, 10): Line(Point(n,0), Point(n,100)).draw(win) for n in range(10, 100, 10): Line(Point(0,n), Point(100,n)).draw(win) win.getMouse() main() 10. Write a complete program that uses a loop to help ask the user for the quantity and cost of each of 10 items. The program should then print out the total cost. An example run of the program should look like: Item 1: Enter quantity Enter cost Item 2: Enter quantity Enter cost Item 3: Enter quantity Enter cost : : Item 10: -> 3 -> 10 -> 10 -> 2.30 -> 4 -> 5 2 Enter quantity -> 6 Enter cost -> 8.50 Your total cost is: 201.18 3 Lehman College, CUNY CMP 230 Exam 1, Version 1 Spring 2011 1. Write Python code that prompts the user for the diameter of a circle, and prints out the circumference of the circle. Useful formulas: circumf erence = π · diameter 2. Trace the Python code below, i.e. indicate the state of the variables as they change. mon = 7 tue = (mon + 6) tue = tue + 3 wed = mon % 4 thu = mon ** 2 wed...
View Full Document

Ask a homework question - tutors are online