{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Exam 1- 2011

# 4 q3 q1 or q2 printq3 cs 115 exam 1 fall 2011 page

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: if y > 2: print(y) print(y) (f) z=4 if z <= 4: print("dog") elif z < 12: print("cat") (g) q1 = 20 < 3 q2 = 3 != 4 q3 = q1 or q2 print(q3) CS 115 Exam 1, Fall 2011 Page 3 of 8 (h) for i in range(3): print("monkey") (i) for i in range(5): print(i) (j) for i in range(0, 10, 2): print(i) CS 115 Exam 1, Fall 2011 Page 4 of 8 Problem 2: 30 points. Write snippets of code to do the following. Your code should only print the requested output. You will lose points for printing additional output. You can assume that all your snippets are enclosed within a main function and that any necessary libraries have been imported. You only need to write the specific lines of code that accomplish each task. (a) Ask the user to enter a price in US cents. Assume the user enters a valid integer. Then print that price in dollars. (b) Assume: o Two variables a and b have alre...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online