Exam 1_Spring 2011

The program should then print out how long it took to

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: ), Point(100,100)).draw(win) Point(100,0)).draw(win) Point(100,50)).draw(win) Point(50,100)).draw(win) win.getMouse() win.close() main() 10. Write a complete program that, using a loop, asks the user for the distance and the speed for each of 10 legs of a trip. The program should then print out how long it took to complete the trip. 11 Lehman College, CUNY CMP 230 Exam 1, Version 5 Spring 2011 1. Write Python code that prompts the user for the radius of a circle, and prints out the area. Useful formulas: area = π · radius2 2. Trace the Python code below, i.e. indicate the state of the variables as they change: mon = 5 tue = (mon - 5) tue = tue + 4 wed = mon % 4 thu = mon ** 2 wed = thu = mon thu = mon - 2 * tue = wed * mon mon, thu = thu, %2 +3 tue mon 3. Write the following formulas in Python: ￿ (a) dist = (x1 − x2 )2 + (y1 − y2 )2 √ (b) area = 3(2 + 3)side2 apothem = 2area 12side 4. Write for loop based Python code to calculate: (a) The product of all the integers from 1000 to 1100. (...
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