Exam 1_Spring 2011

Useful formulas area radius2 2 trace the python code

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: The program should then print out the total distance. 9 Lehman College, CUNY CMP 230 Exam 1, Version 4 Spring 2011 1. Write Python code that prompts the user for the area of a circle, and prints out the radius. Useful formulas: area = π · radius2 2. Trace the Python code below, i.e. indicate the state of the variables as they change: mon = 2 tue = (mon + 6) tue = tue + 4 wed = mon / 4 thu = mon ** 3 wed = thu = mon thu = mon - 3 * tue = wed * mon mon, thu = thu, %2 +2 tue mon 3. Write the following formulas in Python: (a) dist = |x1 − x2 | + |y1 − y2 | √ (b) area = 2(1 + 2)side2 apothem = 2area 8side 4. Write for loop based Python code to calculate: (a) The product of all the integers from 100 to 190. (b) 1.9101 . 5. Write a Python graphics based program that requires the user to click on two points in its window. The program then draws an oval with those two points as opposing corners of the bounding rectangle and print out the length of the diagonal to the screen. 6. Write for loop based Python code to do the following: (a) Print out the multiples of 5 from 195 to 500 inclusive. Note: The ﬁrst t...
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