Exam 2- 2013

# Be very clear with spacing line breaks etc note the

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: 115 Exam 2, Spring 2013 Page 3 of 9 Problem 2: 15 points. What will print to the screen when each of the following snippets of code is executed in IDLE? Be very clear with spacing, line breaks, etc. Note: the parts of this problem are independent. For all parts of this problem, assume that the following functions have been defined. def f1( ): return 6 def f2(x): return x / 2 def f3(s): return (s == s.upper()) def f4(x, y): return f2(y) + x (a) print(f1()) (b) print(f4(6, 30)) (c) if f3("JANUARY"): a = f2(6) else: a = f2(100) print(a) CS 115 Exam 2, Spring 2013 Page 4 of 9 Problem 3: Defining functions (40 points) Define functions to perform the following tasks. Keep in mind the following: • Your functions should NOT ask the user for input. • Your functions should NOT print anything. • Your functions should NOT call sys.exit() to terminate the program. (a) Define a function called perim_sq that… • has one parameter: the side length of a square • returns the perimeter of the square. (b) Define a function called contains_q that… • has one input parameter: a string • returns True if the string contain...
View Full Document

## This note was uploaded on 02/08/2014 for the course CS 115 taught by Professor Staff during the Fall '08 term at Sonoma.

Ask a homework question - tutors are online