Name the five steps to top-down
problem solving as described in the text.
(It's okay if you can't remember the exact wording;
the concepts are more important.)
- Fill in the blank: 
- "Computers are t________s, and computing scientists are t___________s."
- How many bits are in a nibble? __________
- 1011 0110 shifted two right, in binary, is ____________________
- Convert 0x1BE to decimal: _____________
- Convert 1100 0110 from binary to octal: _______________
- What word describes functions which invoke themselves? ___________
- The Python command used to trigger a user-defined exception is
- True or False (circle one): The word Apples_For_Dr.Ho
is a legal Python identifier.
- What is the type of the Python expression 5**2 ? _________
- What Python command is used to convert an integer into a real value?
- Name the two optional reserved words used in the Python program control
construct which corresponds to selection: _____________ ________________
- The first assignment of a value to a variable is called
- A cable modem connection runs at 4Mb/s. Assuming full utilization of
the bandwidth (which never happens in reality), how long would it take to
download a 2GB file? Use binary units. _______________________
- The standard Python function which produces a pseudorandom real number
between 0 and 1 is in the
_______________ standard library and is named _______________ .
- The Python function which counts the number of characters in a string
is named _____________ .
- What English part of speech should a function name be? ___________
- What symbol is used to separate statements in a sequence in C or M2?
- What symbol is used to indicate logical negation in Python? ______
- A requirement imposed by a function upon its parameters, such that
the correctness of the result is not guaranteed if the requirement is
not met, is called a _______________________ .
Name the five computer program flow abstractions described in the text,
and for the four which we covered in class, show how each is done in Python.
Evaluate each of the following Python expressions
exactly as given,
or if it produces an error, describe the error.
Assume each expression is independent of the others.
Assume all necessary imports have been done.
For all expressions, assume the following initialization: 
myPear = "DAnjou"
from math import pi
- 'pi' + 2*'z' + 'a'
- 2 + 1>4 and (5/0 < 1)
- 2.0 + 14 / 4
- 6 ^ 5
- "%03d%s" % (15.189, 'pears')
- "%05.2f" % 2.7182818
- '%.2f' % (19 % 5)
- 'd' + 'b'
- ord('d') - ord('b')
- 'd' - 'b'
- 'b' + 3 == 'd'
What is a namespace? Tell me everything you know about scope rules and
namespaces in Python.
An orchard grows five apple varieties:
Fuji, Gala, Spartan, Rome, and Melba.
The apples I like are Fuji, Gala, and Rome; let this set be denoted by
Let yrFav be the set containing Fuji and Melba.
- Consider the intersection of myFav and yrFav.
Express in words the interpretation of this intersection
in the context of apple preferences. 
- Consider the set difference yrFav - myFav.
Express in words the interpretation of this set difference
in the context of apple preferences. 
- We wish to implement some set operations using bitsets in Python.
Define five Python variables Fuji, Gala, Spartan, Rome, Melba
with appropriate integer values for use in a bitset.
- Using the variables you just defined, define a Python bitset
for yrFav. 
- Write a Python expression for the intersection of
myFav and yrFav. 
What is wrong with the following Python loop? Rewrite it from scratch
in a better way. 
counter = 0
sum = 0.0
numitems = 0
while counter < len(mylist):
sum = sum + mylist[counter]
numitems = numitems + 1
average = sum / numitems
The following Python function has at least eleven errors. Find and fix all of
them. Points will be deducted for "fixing" what are not errors.
""Round a float to the nearest integer (up or down)."""
addhalf := (float++ 0 5) // add 0.5 to float
Define or describe each of the following object-oriented terms:
Modula-2 and C have no built-in string type. What is a string
in Modula-2 or C?
Describe all the differences between Python lists and C arrays.
Explain all the differences between atomic and
aggregate/compound/container data types. Give examples of each.
The file 'input.txt' contains a list of real numbers, one per line.
Write a Python program to read in the numbers from the file and print
their average to the screen. Docstring is required; pseudocode is not.
A certain sequence is defined by t1=0, t2=3, and
after that ti=ti-1 + 2 ti-2, so that
the first few terms of the sequence are 0, 3, 3, 9, 15, 33, 63, ....
On a separate paper, write a recursive Python function to compute
the nth term of this
sequence. Docstring and preconditions are required; pseudocode is not (but may
be good for partial credit).
A dynamic system that is being accelerated at a constant acceleration
a has its initial velocity u, final velocity v, and
the distance travelled d related by the formula
v2 - u2 = 2ad.
On a separate paper,
write an interactive Python program that can calculate either
a in terms of the others. Use at least one function.
Docstrings are required for the program and all functions.
Pseudocode is not required (but may be good for partial credit).