# CS21: Quiz 2 Study Guide

### In addition to all concepts from Quiz 1,

#### You should be able to define the following terms:

• the standard design pattern
• the accumulator design pattern
• the long and bool types

#### You should understand and be able to use the following Python concepts:

• basic arithmetic expressions using +, -, *, /, **, %, and abs()
• conversion between the int, float, and long types
• import math, dir(), and help()
• the empty string ""
• string concatenation with +
• string repetition with *
• string indexing
• string slicing
• for loops over strings
• len()
• tracing a program
• control-flow diagrams
• if, if/else, if/elif/else
• the relational operators <, <=, ==, >, >=, !=
• the boolean operators and, or, and not.
• short-circuiting with and and or

#### Practice problems:

1. Programming exercises 1, 3, and 11 on page 228-229 of Zelle.
2. True/false questions 1, 2, 4, 7, 8 on pages 225-226 of Zelle.
3. Multiple choice problems 2, 3, 5, 7, 10 on pages 226-227 of Zelle.
4. Discussion question 1, parts (a) through (f) on page 116 of Zelle.
5. Discussion questions 1 and 2 on page 71 of Zelle.
6. Trace the behavior of the following program:
```  x = 3
print 0,x
for i in range(1,6):
if x % 2 == 0:
x = x / 2
else:
x = (3*x+1)/2
print i,x
```