Topics Midterm 2 CS112 – Spring 2008
Check for updates… this document will most likely be updated a few times!
Last update: 4/7/08 8:20 AM
Functions
- Know how to invoke a function
- Define a function that returns something
- Multiple return values?
- What is variable scope
- Know that all functions return something… if not defined, they return None
- Pass by value versus pass by reference
o What happens when things get modified in a function?
• Immutable variables (String, int, float, char)?
• Mutable variables: Lists
- How to create and use default parameters
- How to create and use named parameters
Statements versus Expressions
- Know the difference between statements and expressions and be able to identify either
Datatypes
- Know how to use and modify lists (mutable)
- Know how to use and modify int/float/char/String (immutable)
- Know how to slice out portions of a list or String (it’s the same for both!)
Debugger
- What is step versus next versus out
- What is a breakpoint?
- Debugging is the process of finding and fixing problems in programs. Know that
Errors
- Know how to identify and define these error types:
o syntax - incorrect syntax due to
spelling errors, missing operators, etc. ,
o run-time - compiled/interpreted,
but crashes when encounters certain data sets
o logic errors - executes, but
provides incorrect or inconsistent outputs
Loops/Decisions
- How do you create a for loop (definite loop)
- How do you create a while loop (indefinite loop)
- Know what break does
- Know what continue does
- Know how to use if/elif/else
- How to create a text menu using a loop
File IO
- What can happen if you don’t close the file?
- Processing sequence: open, read, close
- File modes, what are the differences (r, w, a)
-
Know how to read files using at least one of these: read,
readline, readlines, for loop method. If I ask you to write code to
read a file, you should know how to do it.
- If I ask you how to write code to write a file, you should know how to do it
- What is \n ?
- What do I do with \n when reading from a file? When writing to a file?
Graphics
- General process to create a widget
o Know specifically how to create a Label and Button!
- What does pack do?
- What does the mainloop do? Can you write it in pseudocode?
- What is a callback? How do I set it for a Button?
-
Given documentation for a widget, know how to read and use it.
For example, given the REFERENCE SECTION ONLY can you use this:
http://effbot.org/tkinterbook/button.htm (Note, I won’t
give you Button, you should know how to use it without docs, but given
docs like this could you use a widget you haven’t seen before?)
- Know what pack does… and options: side, padx, pady
- Know how to create a Frame, and root window
- What does bind do?
o How do I use it to capture mouse
clicks (specifically location of the click)
- Passing functions as parameters instead of calling them… what is the difference in syntax?
- Identify a program as batch or event based
- What is a Dialog box? Why are there libraries of them?
o Know how to ask a Yes or No question using them.
- How do you add a title to your window?
Objects/Classes
- What is the difference between a Class and an Object?
- Know how to create a class and use it
o What is self?
o Can you write a simple class that holds data and defines operations?
- Know how to construct an Object:
o Example: myLbl = Label( …. ) # Construct a label
- Know how to call an operation on an object:
o Example: myLbl.someOperation()
- Know how to use (define and retrieve) instance variables
Boolean Logic and Algebra
- Know how to simplify a boolean expression using DeMorgan’s laws
All topics from Midterm 1