CS104 Final Test Review

advertisement
CS104 Final Test Review
Victor Norman
Calvin College
What is on the test?
 Everything from the beginning of the semester. Especially…
 Syntax errors.
 Questions from previous tests.
 Questions about classes, superclasses, objects, inheritance, constructors,
etc.
Early topics
 Variables – what they mean, etc.
 Assignment statements (vs. ==, lhs vs. rhs, etc.)
 Operators: *, /, %, //, etc.
 Basic types:
 int
 float
 str
Functions, etc.
 range()
 Functions
 function definitions
 function calls
 parameters, arguments.
 return
 What happens when you don’t return a value from a function.
 return vs. print
 Flow of control
For loops, etc.
 Simple for loops
 Syntax
 Meaning
 “Definite” iteration
 range(len(<sequence>))
 Item-based vs. Index-based loops
Boolean expressions
 Boolean operators:
 ==, <=, in, etc.
 Logical operators:
 and, or, not
 Complex boolean expressions
 Containing multiple ands and ors.
If Statements
 if, if-else, if-elif-else syntax and meaning.
 if: one-way decision
 if-else: two-way decision
 if-elif-…-else: n-way decision
 Nested if statements
While loops
 “Indefinite” iteration
 boolean expression evaluated every time,
 body executed if the boolean expression is true.
Strings and Lists and Tuples
 Mutability vs. immutability
 implications of this.
 Indexing (subscripting)
 Slicing
 Mutator methods on lists (like sort() and append())
 Similarities and differences between lists and tuples
 “” (or ‘’, or “”””””, or ‘’’’’’)
 []
 (,)
 Returning a tuple, and tuple assignment
Files, etc.
 open() a file, reading from it, close() it.
 File objects.
 In function definitions: optional parameters with default values.
 How print actually works.
 evaluates its arguments
 converts each to a string
 outputs each, separated by a space
Classes and Objects
 Lots of definitions
 class definition
 Object instantiation
 Calling methods on objects.
 Constructor definition.
 Creating getters and setters.
 Initializing object attributes (instance variables, state, etc.)
Classes and objects (2)
 Overriding pre-defined special methods
 __init__
 __str__
 __add__
 etc.
Inheritance
 What it means, and why it is useful.
 How you code up inheritance.
 Calling a superclass constructor.
Download