Topics Final CS112 – Spring 2009
Check for updates… this document will most likely be updated a few times!
Last update: 4/26/09 5:15 PM
- Everything from the 1st midterm... the final is cumulative and will cover the entire semester! Check that review also!
Python basics
- An algorithm is an ordered set of steps to solve a problem
- Pseudocode is a syntax-free language to specify an algorithm in program-like syntax
Datatypes
- Know how to use and modify lists (mutable)
- Know how to use and modify int/float/char/String (immutable)
- Know how to use and modify tuples (immutable)
- Know how to use and modify dictionaries (mutable)
- Know how to slice out portions of a list or String (it’s the same for both!)
- Know how to create all of these!
- Know the difference between a sequential and mapping datatype. Which are they in Python?
- What is the difference between a tuple and a list?
- Know that tuples ad Strings are immutable and WHAT THAT MEANs... what list operations do/do not work with tuples?
Loops/Decisions- Can you use a for loop to iterate a specific number of times? Know how
- Can you use a for loop to iterate over a sequential datatype? Know how
Functions
- Know how to invoke a function
- Define a function that returns something
- What is variable scope
- Know that all functions return something… if not defined, they return None
- Pass by value versus pass by reference
- What happens when things get modified in a function?
- Immutable variables (String, int, float, char)?
- How to create and use default, named or positional parameters
Pickling and Shelves
- What is pickling used for?
- What happens if you pickle/unpickle in different orders
- What is pickling called in other languages?
- Why do we use shelves (what is the advantage over pickling?)
- How do you use shelves?
Graphics and GUIs
- General process to create a widget
- Know specifically how to create a Label, Button, Text entry box!
- How do I create changable labels or buttons?
- What does grid do?
- How can a create cells that span columns or rows?
- How can I align widgets into cells?
- How can I add space around a cell?
- 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 how to create the root window
- What does bind do?
- How do I use it to capture mouse clicks
- 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?
- 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
- Can you write a simple class that holds data and defines operations?
- Know which method to define to create a string representation of an object
- Know how to construct an Object:
- Example: myLbl = Label( …. ) # Construct a label
- Know how to call a method (operation) on an object:
- Example: myLbl.someOperation()
- Know how to use (define and retrieve) instance variables
- Know how to make public and private attributes and methods and what that does
- Be able to explain encapsulation and abstraction
Errors (if we get to this in class)
- 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
Debugger (if we get to this in class)
- What is step versus next versus out
- What is a breakpoint?
- Debugging is the process of finding and fixing problems in programs. Know that
- Exceptions (if we get here in class)
- Know the try/except format and how to write it
- Know what happens with an 'except:' block
- Know what happens with multiple except blocks
- Know how exception propagation works
Remember to bring a scantron!!!
How to Study
Some
help in my opinion for how to study. First: Start EARLY! Many studies
show studying a little over a long period of time is much better than
studying a lot right before the test!
1. First, make sure you understand fully the previous midterm.
Do this by HIDING the answer from yourself (cut some paper and tape it
over your answers), and then re-answer the questions... did you miss
any? Try writing the answers in IDLE and seeing what happens.
2. Make sure you understand the items on this study guide -
Work through examples on the slides and the projects/labs. Make sure
you can write the code... don't just read and it and assume you know
it. It's a lot different to read code than it is to write code!
3. Do as many practice problems as you can from the labs/projects/book... work on understanding the concepts and the syntax. Try to fix errors when they occur.
4. Ask questions
if you don't understand something. Post questions to Blackboard for
things you don't understand. Email me or the TAs also if you need help.
Some sample programming problems to practice
- Write a function to find the most common number in a list of numbers passed into the function
- Write a function that takes a list of number and returns a count of how many times a number repeats in a row.
For example:
Input: 23224233345542 Output: 4
Input:
555
Output: 2
Input
5515
Output: 1 - Write a
function that finds the largest and second largest number in a list. Do
this WITHOUT using the sort function. Return both values from the
function
- Write a program that displays the text of a button if you place your mouse over the button (but do not press the button)
- If we get to exceptions: Write
a function that can capture multiple types of exceptions -- NameError
and ZeroDivisionError and then all other exceptions. Take input from
the user that could make any of those happen, and print out a specific
error message when any error occurs