Quiz 1 Info
Quiz 1 Information
Quiz details

Quiz 1 will be held on Thursday, July 13th.

The quiz will be held at:
 B1 class (MTR 9:0011:30am): Quiz will be 9:009:30am

We will still meet for class the day of the quiz.

You must bring your BU ID to the quiz, so that we can check it when you turn in your quiz.

You will have 30 minutes for the quiz.

You may not use any electronic devices during the quiz.

Once you leave the quiz room, you may not return, so please use the restroom ahead of time.

The quiz will include questions similar to the ones posed in lecture–both the clicker questions and the openresponse ones. However, these questions will not be multiplechoice. You will need to determine and write the answer without a list of options to choose from.

In addition, there will be questions that ask you to write a function or a short program, similar to the problems from the homework.
Material covered
The quiz will focus on the material that we have discussed in class from the beginning of the summer session through Monday, July 10th (not including list comprehensions). This corresponds to the following readings:

from CS for All:
 Chapter 1
 Chapter 2: everything but section 2.8, which we skipped because we had read similar material from the other textbook (see below)

from How to Think Like a Computer Scientist:
 Variables and Parameters Are Local
 Functions Can Call Other Functions (the two paragraphs before the CodeLens example, and the one that comes after it)
 Flow of Control Summary
Note: You are not responsible for details from the case studies in the readings (e.g., the information about how RSA encryption works). However, you are responsible for the programming and problemsolving concepts that those case studies were used to illustrate.
In addition, you should be familiar with concepts that were introduced in the preclass videos, inclass discussion, or on the homeworks that were not covered in the readings.
Preparing for the quiz

One way to prepare is to review the readings and lecture notes and make a summary of the key points in your own words. “Boiling down” the material in this way is a great way to ensure that you really understand the key concepts.

We also encourage you to do practice problems. Options include:

redoing the questions posed in lecture–both the clicker questions and the openresponse ones. The online lecture notes include both the questions and–on the next slide–the answers.

the following questions from CodingBat:
 any question from Warmup1
 any question from String1
 any question from List1
 any question from Logic1
 the double_char problem
 the count_evens problem
 the sum13 problem

the additional practice problems found below.
When working on practice problems, try to come up with your answers on paper, rather than through a trialanderror approach on IDLE or in another programming environment. This will be give you an experience that is similar to the one that you have during the quiz.


Feel free to post questions on Piazza (using the
quiz1
tag) or to email the course account (cs111staff@cs.bu.edu
).
Additional practice problems

Given the string
s = 'Columbus'
, evaluate the following:s[0]
s[0:1]
s[1:]
s[1]
s[3: :1]
s[2: :2]

Given the list
myList = [3, 2, 1, [4, 7], 5]
, evaluate the following:myList[0]
myList[0:1]
myList[1]
myList[3]
myList[:2]
myList[2: :2]

Evaluate the following:
'a' in 'backache'
[1, 2, 3] + [[11, 13, 12][1]] + [22, 33, 44, 55][1:]

What is printed by the following working Python program?
def dog(x): print('in dog, x is', x) y = cat(x  1) + cat(x + 2) print('in dog, y is', y) return y def cat(y): print('in cat, y is', y) x = rat(y * 2) + 3 print('in cat, x is', x) return x def rat(x): print('in rat, x is', x) return 2 * x y = dog(3) print('at this level, y is', y)

What is printed by the following working Python program?
def mystery(x): print('x is', x) if x < 1: return 2 else: p = 6  mystery(x  1) print('p is', p) return p y = mystery(3) print('y is', y)

Write a function
count_ones(s)
that takes in a strings
of'0'
s and'1'
s and returns the number of'1'
s in the input. Use recursion. 
Write a function
swap_bits(s)
that takes in a strings
of'0'
s and'1'
s and returns a string in which each bit ins
has been swapped/replaced with the other bit. For example,swap_bits('101011')
should return'010100'
. Use recursion. 
Write a function
num_divisors(n)
that returns the number of integers from 1 ton
(inclusive) that dividen
evenly. For example,num_divisors(42)
should return8
, because 1, 2, 3, 6, 7, 14, 21, and 42 are all divisors of 42. Use recursion. 
Write a function
count_transitions(s)
that takes in a strings
of'0'
s and'1'
s and returns the number of times there is a transition from a'0'
to a'1'
or viceversa in that input string. For example,count_transitions('1110110000')
should return3
. Use recursion.