This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ), Point(100,100)).draw(win)
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
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.
- Fall '13