| IPL / Mr. Hansen | Name:
  _________________________ | 
Test through Chapter 10 of Python Textbook
| Rules | 
 | 
|  |  | 
|  | Part I: Terminology and Definitions (60 points; 5
  points per numbered problem) | 
|  |  | 
| 1. | Numeric values that have no
  decimal portion (what we call integers in high school mathematics courses)
  have type ______________ in Java and ______________ in Python. | 
|  |  | 
| 2. | Since there is often a need
  to store and use numeric values that may
  have a decimal portion, floating-point types are provided in both Java and
  Python (and nearly all other __________________________________ languages,
  for that matter). | 
|  |  | 
| 3. | The types used for floating-point
  values are generally ____________ in Java and ____________ in Python. | 
|  |  | 
| 4. | Lines of code that are
  useful during testing and debugging, but are generally not included (or are
  commented out) in the final source code are called ____________________ . (Hint: The
  term begins with the letter S.) | 
|  |  | 
| 5. | It is generally considered
  an antipattern to duplicate a block of code in two
  or more places, because then a bug fix to one block will not be reflected in the
  other place(s) unless the maintenance programmer happens to remember to
  change all occurrences. The customary solution for this antipattern
  is to _____________________ (hint:
  starts with an E) the functionality of that block of code into a “subroutine,”
  which in Java is generally called a _____________________ (hint: does not start with the letter
  F). | 
|  |  | 
| 6. | As software developers, we
  are by nature abstract thinkers. We have to be, because we are always
  abstracting reality in the form of defined procedures, called
  _____________________ (hint: starts
  with an A), and various data structures that model the relationships between
  objects in the real world. When we abstract a subroutine in Python,
  regardless of whether or not the subroutine returns a value, we are creating
  what Python and most other 3GLs call a _____________________
  . | 
|  |  | 
| 7. | When an object no longer
  has any reference, i.e., no longer has anything pointing to it, it can no longer
  be accessed reliably by any code. Therefore, the compiler has to perform a
  procedure called __________________________________________ (2 words) in
  order to prevent memory leaks. | 
|  |  | 
| 8. | An _____________________ is defined as “a named collection
  of values, where all the values have the same type, and each value is
  identified by an index.” | 
|  |  | 
| 9. | A deterministic program is
  one that __________________________________________ | 
|  |  | 
|  | __________________________________________________________________
  . | 
|  |  | 
| 10. | Computer programs that need
  to have unpredictable behavior (for example, single-player games) use
  __________________________ (hint: starts
  with a P) number generators to generate values that appear to be random, but
  which are actually the product of a deterministic computation. | 
|  |  | 
| 11. | Explain briefly what is
  meant by a slice (string slice, that is) in Python. | 
|  |  | 
|  |  | 
|  |  | 
|  |  | 
|  |  | 
|  |  | 
|  |  | 
| 12. | What term is used for a
  scratch variable that is usually initialized to 0 (or 1) and then incremented
  each time through a loop? ________________ | 
|  |  | 
|  | Part II: Program Snippets (10 pts. each) | 
|  |  | 
| 13. | Program A: Translate the
  following into Python, line by line, including the comment. Do a straight
  translation with no editing or improvement. String
  k="";    //null string int i; for (i=0; i<=5; i++) {     k=k
  + "ba";     System.out.println(k); //leave typo (k for i) as is } System.out.println(k); | 
|  |  | 
| 14. | Program B: Translate
  program A back into Java, using no
  variables and no looping. In
  other words, simply give a few System.out.println lines
  that produce the same output. Easy! | 
|  |  | 
| 15. | Program C: Write a Python
  function (2 lines preferred) that de-obfuscates the code below and that uses
  a self-documenting function name. def gazillivator(i, x):     #
  assume i>=0     #
  assume i is an int, and x
  is a float     j=1     xx=1     while
  j<=i:         xx*=x         j+=1     return
  xx | 
| 16. | Program D: Write a two-line Java method (one line plus
  the public static double gazillivator line) that
  does the same thing as Program C. |