22C:16 CS:1210 Exam 2
April 5th, 6:30 pm to 8:30 pm
Instructions:
This is an open notes exam and you have 2 hours to complete it. There are 4 problems in
the exam and these appear on 8 pages.
Make s
22C:16 CS:1210 Exam 1
Feb 22nd, 6:30 pm to 8:30 pm
Instructions:
This is an open notes exam and you have 2 hours to complete it. There are 4 problems in
the exam and these appear on 7 pages.
Make su
22C:16 (CS:1210) Quiz 8
You have 20 minutes to complete this quiz.
1. Suppose that D is the dictionary cfw_"what": "why", "are": "what", "you": "what",
"why": "hello", "next": "are", "hello": "next".
22C:16 (CS:1210) Quiz 7
You have 20 minutes to complete this quiz.
Evaluate each expression and write down its value. Assume that (i) grow is a function that takes
two parameters a and b and returns [
22C:16 (CS:1210) Quiz 6
You have 20 minutes to complete this quiz.
1. Dene a function called moveNegatives that takes a list L of integers as a parameter.
The function is required to return a new list
22C:16 (CS:1210) Quiz 6
You have 20 minutes to complete this quiz.
1. We want to write a function notNeighbors that takes two words word1 and word2 as
parameters and returns True if word2 cannot be ob
22C:16 (CS:1210) Quiz 5
You have 20 minutes to complete this quiz.
1. Consider the following function denition.
def test(a, b, c = 20, d = "12"):
return str(b) + str(c) + d + a
For each of the functio
22C:16 (CS:1210) Quiz 5
You have 20 minutes to complete this quiz.
1. Consider the following function denition.
def test(a, b, c = 20, d = "12"):
return str(b) + str(c) + d + a
For each of the functio
22C:16 (CS:1210) Quiz 5
You have 20 minutes to complete this quiz.
1. Consider the following function denition.
def test(a, b = 0, c = 2, d = "12"):
return str(a - c) + d + str(b)
For each of the func
22C:16 (CS:1210) Quiz 3
You have 20 minutes to complete this quiz.
1. Suppose that variable x has value 18 and variable y has value 13. Evaluate each of the
following boolean expressions.
(a) (x != y)
22C:16 (CS:1210) Quiz 2
You have 20 minutes to complete this quiz.
1. Write down the output produced by the following program:
n=5
m=2
while m <= n:
if (m * n) % 4 = 0:
print "Line 1", n, m
m=m+1
else
22C:16 (CS:1210) Quiz 2
You have 20 minutes to complete this quiz.
1. Write down the output produced by the following program:
n=6
m=3
while (n - m) < 6:
if (m * n) % 4 = 0:
print "Line 1", n, m
m=m-1
22C:16 (CS:1210) Quiz 1
You have 20 minutes to complete this quiz.
1. This is our rst Python program, intToBinary1.py. What output does it produce for
input 22?
n = int(raw_input("Type a nonnegative i
22C:16 (CS:1210) Quiz 1
You have 20 minutes to complete this quiz.
1. This is our rst Python program, intToBinary1.py. What output does it produce for
input 19?
n = int(raw_input("Type a nonnegative i
22C:16 (CS:1210) Quiz 1
You have 20 minutes to complete this quiz.
1. This is our rst Python program, intToBinary1.py. What output does it produce for
input 21?
n = int(raw_input("Type a nonnegative i
22C:16 CS:1210 Exam 2
April 5th, 6:30 pm to 8:30 pm
Instructions:
This is an open notes exam and you have 2 hours to complete it. There are 4 problems in
the exam and these appear on 8 pages.
Make s
22C:16 CS:1210 Exam 1
Feb 22nd, 6:30 pm to 8:30 pm
Instructions:
This is an open notes exam and you have 2 hours to complete it. There are 4 problems in
the exam and these appear on 7 pages.
Make su
22C:16 (CS:1210) Quiz 10
You have 20 minutes to complete this quiz.
1. Write down the output produced (via the print statement) when the function given below
is called as
generalMergeSort([5, 6, -2, 1
Quick Sort
MAY 1ST, 2013
Quick Sort: Review
def generalQuickSort(L, first, last):
# Base case: if first = last, then there is only one element in the
# slice that needs sorting. So there is nothing to
22C:16 Practice Problem Set 10
Morning Section: Complete before Tuesday, 4-30-2013
Evening Section: Complete before Monday, 4-29-2013
These practice problems are all on recursion.
1. This question is
22C:16 (CS:1210) Quiz 9
You have 20 minutes to complete this quiz. This quiz depends on the searchWordNetwork
function that was part of the program playLaddersGame2.py. Code from this function appears
22C:16 (CS:1210) Quiz 9
You have 20 minutes to complete this quiz. This quiz depends on the searchWordNetwork
function that was part of the program playLaddersGame2.py. Code from this function appears
22C:16 (CS:1210) Quiz 9
You have 20 minutes to complete this quiz. This quiz depends on the searchWordNetwork
function that was part of the program playLaddersGame2.py. Code from this function appears
22C:16 (CS:1210) Quiz 7
You have 20 minutes to complete this quiz.
Evaluate each expression and write down its value. Assume that (i) concat is a function that
takes two parameters a and b and returns
22C:16 (CS:1210) Quiz 5
You have 20 minutes to complete this quiz.
1. Consider the following function denition.
def test(a, b = 0, c = 2, d = "12"):
return str(a - c) + d + str(b)
For each of the func
22C:16 (CS:1210) Quiz 5
You have 20 minutes to complete this quiz.
1. Consider the following function denition.
def test(a, b = 0, c = 20, d = "12"):
return str(b) + str(c) + d + a
For each of the fun
22C:16 (CS:1210) Quiz 4
You have 20 minutes to complete this quiz.
1. Consider the following expressions. For each expression, rst determine whether the expression is well-formed or not. For each well
22C:16 (CS:1210) Quiz 4
You have 20 minutes to complete this quiz.
1. Consider the following expressions. For each expression, rst determine whether the expression is well-formed or not. For each well
22C:16 (CS:1210) Quiz 3
You have 20 minutes to complete this quiz.
1. Suppose that variable x has value 7 and variable y has value 8. Evaluate each of the
following boolean expressions.
(a) (x >= y) a
22C:16 (CS:1210) Quiz 3
You have 20 minutes to complete this quiz.
1. Suppose that variable x has value 11 and variable y has value 6. Evaluate each of the
following boolean expressions.
(a) (x/y < 2)