Study Topics for Final Exam
Of course, the topics on the midterm are fair game also,
since the final is comprehensive.
They are posted at the bottom of the main CS 115 page.
- Try / except control structure - syntax and semantics
- Strings
- strings are immutable
- string comparison (ASCII)
- string operators and methods
- concatenation (+)
- [] (indexing)
- [:] (slicing)
- the find method
- len function for lists and strings
- strip
- lower, upper
- split function
- operates on strings to produce lists of strings
- split with no argument (uses whitespace)
- split with argument given
- what is whitespace? space, newline, tab
- what is a "delimiter"?
- "in" operator, "not in" operator
- traversing and processing strings with loops (2 ways)
- string typecasts str()
- Functions
- parameters/arguments
- scope - local vs. parameter vs. global
- lifetime of a variable
- design of a function - what is in the design? 3 P's
- when can a function change a parameter permanently
- functions which return values vs. functions which don't
- how to call
- how to write the definition of
- return statements
- functional cohesion - "a function should do one job,
do it well, and do nothing else"
- unit testing
- scaffolding: stubs and drivers
- objects / methods / dot notation - syntax, semantics
- Lists (arrays)
- properties
- lists are heterogeneous (elements don't have to be all the same type)
- have direct (or random) access (can refer to any element without having to access the others before it)
- don't have to stay the same size all the time - can get larger or smaller
- ordered - numbered in order using subscripts from 0 up to n-1 - no gaps
OR from -n to -1 (from right end of list)
- mutable - their elements can be changed
- slice, copy() and deep copy (to avoid aliasing)
- creating lists - 1 and 2 dimensional
- initializing a list
- when is a subscript to a list out of range?
- passing a list as an argument to a function
- manipulating the elements of a list
- len function, append method, concatenation
- membership in a list "in" "not in"
- index method
- slicing a list
- difference between "for i in list" and "for i in range(len(list))"
- reverse, max, min, sum, count functions
- sorting a list using sort method - what does it RETURN? None!
- comparison of lists and external files
- debugging
- breakpoint
- stepping (Step into, Step over, Step out)
- call stack
- debugger jobs: slow down the program (allow you to step through one
line at a time), show variables' values, show function calls (call stack)
- Structured Programming
- control structure versus data structure
- four kinds of control structures
- general guarantee for all control structures (One entrance, One exit)
- sequence
- what is it?
- guarantees - executed in order, started at first step, ended at last step
- selection
- what is it?
- guarantees - entrance at condition, one branch or the other executed, never both, after exit of either branch, continues at same point
- dead code - don't do it! logically impossible to execute
- iteration
- what is it?
- guarantees - entrance at condition, exit only from condition at top
- infinite loop - don't do it!
- module (function)
- what is it?
- guarantees - entrance at top of definition, exit at bottom, returns to point it was called from
- can have dead code too! don't put code after return statement!
- Selection
- bool constants - True, False
- relational operators <, >, etc.
- logical (boolean) operators - and, or, not
- precedence with all other operators
- truth tables - how do the operators work?
- DeMorgan's Laws not (A and B) is the same as not A or not B,
not (A or B) is the same as not A and not B
- if statements
- nested if statements
- which if does the else go with?
- if - elif statements "open" vs. "closed"
- tracing ifs
- test cases for testing ifs
- comparing floats
- comparing strings - ASCII ordering
- Random numbers
- deterministic - what does it mean?
- randint, randrange, choice, random - what do they each
return? what arguments do they have?
- what does seed do? what does Python use for the seed if
you do not call the seed function?
- Loops - for and while
- syntax
- for loops
- how does the range function work? 1 argument? 2 arguments? 3 arguments?
- while loops - syntax and semantics
- which loop do you use for which purpose? (definite vs. indefinite)
- control logic - counter-controlled and sentinel-controlled
- infinite loops
- What is the pattern for sentinel logic?
- What is the pattern for input validation?
- What are the THREE test cases you use to test a loop?
- accumulators and counters- how they work
- the prev/curr pattern - how does it work?
- flags
- what type are they? how are they used?
- initializing them
- setting them
- testing them
- nested loops
- tracing loops
- break - how does it work and why you do NOT use it!
- Graphics (Zelle)
- class versus object
- constructors like GraphWin(), Line(), Point()
- objects do things (functions) - those things are methods
- dot notation for referring to a method of an object
- clipping on a graphics window
- coordinate system - setCoords
- methods for draw, setFill
- "get" methods versus "set" methods
- aliasing, clone method
- Files
- why use files
- how to open / process / close
- 3 steps to using them - open, use them, close
- "opening a file to write to is constructive (creative) and destructive"
- input data from files (know how much they read, what type they return)
- read
- for line in infile
- delimiter for lines = newline character
- output to files
- print(stuff, stuff, stuff, file=file object)
- fileobject.write(string) - more limited, must be writing one string
- buffer
- file modes "r","w","a"
- sequential access