Exam Coverage: sections from ThinkCS
assigned in the reading and homeworks
(
from Chapters 1-12, 17&18, only
4.4-4.7 of chapter 4); Zelle
Chapters 1 - 11 (Chapter 9 is worthwhile but I didn't assigned it)
(on library reserve)
The final exam is comprehensive; the course builds on the fundamentals presented in lecture and the text, so there may be questions about topics covered on previous exams and questions on other topics which use them:
for
and
while
)Examples from lecture, in-class exercises, homeworks, labs, and the text will figure in the exam.
len
and max
.Strings. We remember strings (the str
type), right? Know the basics, using the slice operator, and common
string methods.
Lists (single and nested). Know how to create, initialize, and
build single or nested lists. Be able to use index variables to access
data in a list (for example as in weatherData/WeatherClass).
Understand how data is stored in rows and columns in a nested list
structure (as the Connect-4 and CheckerBoard
examples). Review programs from lab and homework assignments, including
list methods such as append
. Common operations on
numerical data in lists including finding a value in a list, summing all
the values in a list, averaging the values in a list.
Range. How the range
function works when given two or three arguments. Use with the
list conversion operator and in definite loops.
Tuples. The main use for tuples was to return more than one value
from functions, as in the raceway.py
example. We also saw them used in assignment statements in a similar way.
Dictionary. Storing key/value
pairs in simple and nested dictionary structures along with the common dict
methods. Primary examples come from the Collections
Activity and Chapter 12 of ThinkCS.
Processing nested sequences, especially nested lists, generally requires
nested loops. For example, the code below accesses and sums all the values
in a nested list. To check your understanding of the what each loop does,
insert a print function after the outer for loop to print row
.
You could also print x
each time through the inner
loop. Or, visualize the execution using PythonTutor.com.
values = [ [1,2,3], [4,5,6], [7,8,9], [10,11,12] ]
sum = 0 for row in values:
for x in row: sum += x print(sum)
Know the basics of opening, reading
from, writing to, and closing
files. Since the data in the file is typically read in sequence, they are
considered sequences and are often read using for
loops.
The idea of class types that describe attributes and operations. Basic
class design, object creation, constructors (__init__) and method calls.
We also have the concept of scope of variables within a class along with
local variables in methods. Recall the class
variables such as the avagadro
variable used in the Atom
example (atom3.py).
We spent some time on the role of __init__
in constructing new objects of class
types, the role of self
in defining new instance variables, and using self
to access variables and methods inside class definitions.
Know how we derive new classes from existing classes and use them in programs. Some terminology: base class (superclass) and derived class (subclass); inheritance and composition (the relationships IS-A and HAS-A); class hierarchies
Miscellaneous Sources. Some concept and coding questions may be derived from lab, homework exercises and examples given in the textbook and in lecture. You might read over some of the exercises at the end of sections and chapters that we covered in the text and at least think about how to solve them.
Questions? If at any time you find that you cannot do a problem or understand a concept or a how a question on a previous test should be solved, contact me by e-mail or during office hours, including the afternoon of Reading Day. Bring as many questions as necessary to clear up anything you can't figure out on your own.
Come Equipped. You may bring your own notes and textbook (no sharing). No calculators, laptops, magnifying lenses, or Walkmans needed or allowed for the final; caffienated beverages okay.