This preview shows page 1. Sign up to view the full content.
Unformatted text preview: 0. Write a complete program that uses a loop to help ask the user for the quantity and weight of each
of 10 diﬀerent types of cars. The program should then print out the total weight of all the cars. 5 Lehman College, CUNY CMP 230 Exam 1, Version 2 Spring 2011 1. Write Python code that prompts the user for the diameter of a circle, and prints out the area of the
circle. Useful formulas: area = π · radius2 , diameter = 2 · radius
2. Trace the Python code below, i.e. indicate the state of the variables as they change.
mon = 9
tue = (mon + 6)
tue = tue + 3
wed = mon % 4
thu = mon ** 2
wed = thu = mon
thu = mon - 2 *
tue = wed * mon
mon, wed = wed, %2 +2
mon 3. Write the following formulas in Python:
(a) y = mx + b
(b) area = 2(1 +
apothem = √ 2)side2 2area
8side 4. Write for loop based Python code to calculate:
(a) The product of all the integers from 100 to 200.
(b) 330 .
5. Write a Python graphics based program that requires the user to click on two points in its window.
The program then dra...
View Full Document
This document was uploaded on 03/24/2014 for the course CMP 230 at Lehman College.
- Fall '13