Name: ________________________________________________________
Umail Address: ________________________________________@ umail.ucsb.edu
Circle one: 9am 10am 11am noon
Please write your name only on this page. That allows me to grade your exams without knowing whose exam I am grading.
This exam is closed book, closed notes, closed mouth, cell phone off,
except for:
There are 100 points worth of questions on the exam, and you have 75 minutes to complete the exam.
A hint for allocating your time—on your first pass through the exam:
If you do that, you'll complete your first pass thorugh the exam in 50 minutes, and still have 25 minutes to
"error"
"error"
(16 pts) Here are two possible definitions for the function squared
, labelled as definition A and definition B.
Definition "A"  Definition "B" 

def squared(x): return (x * x) 
def squared(x): print (x * x) 
Below are several examples of output from code that includes a function call to the squared function.
Your job: decide which version of squared was used—or whether it is impossible to tell from the output given.
In each case, simple circle A, B, or "can't tell".
Code  Circle one answer 

>>> squared(7) 49 >>> 
A B can't tell 
>>> for i in range(4): squared(i) 0 1 4 9 >>> 
A B can't tell 
>>> 2 * squared(3) 18 >>> 
A B can't tell 
>>> for i in range(4): print(squared(i)) 0 None 1 None 4 None 9 None >>> 
A B can't tell 
The first row is done for you an an example
under each expression, fill in an equivalent expression that doesn't use not 
Value of expression when w='foo'; x=2; y=3; z=[1,4] 

type(z) != list 
False 









makeOneString()
that takes a list of strings, and produces a single string that is the concatenation of all the strings in the list. def makeOneString(strList): """ strList should be a list of strings (if not, return False) if it is, return a single string which is the concatenation of all strings in the list """ # Fill in the blank with code that checks whether the parameter is a list if _______________________: return False # Initialize an empty stringwe using the accumulator pattern on result result = "" # fill in the last part of the for loop line so that # it iterates over the indices (indexes) of the list for i in _________________________________: if (type(strList[i]) != str): ___________________ # do what is appropriate else: _____________________ # do what is appropriate return ____________ # return the completed string check_expect("test 1",makeOneString([]),'') check_expect("test 2",makeOneString(['IV','Rocks']),'IVRocks') check_expect("test 3",makeOneString(['I','Like','UCSB']),'ILikeUCSB') check_expect("test 4",makeOneString('bogus'),False) check_expect("test 5",makeOneString(['Best','Friends',4,'Ever']),False) 
Total points: ?