Final Exam Review
Survey Results
- 8/12 students submitted the survey
- 4 wanted conceptual-only, 4 wanted conceptual & programming – conceptual-only final exam
- Format for review:
- Lecture-style: 44%
- Open class: 29%
- Question & Answer: 27%
- Preferred Focus of Review:
- Concepts: 75%
- Programming: 25%
- Ranking of topics:
- Classes: 27%
- Modules: 19%
- Exception Handling: 17%
- Dictionaries and Sets: 17%
- Functions: 14%
- Midterm Material: 7%
Classes
Requests:
- would like to see some detailed examples on classes, as well as more information on when they are useful/when they aren't.
- review of data aggregation for secure set methods (copies)?
- Data Aggregation. If we could have another example like the eye and hair color program, only much shorter and more simple, that would be wonderful
- data aggregation
- What is the property function? How to make a field private? How do methods access and use fields that are private? How does the end user access and use private fields?
- No specific questions, just need more conceptual understanding and practice.
- These lectures were just overall where I become very lost in the course. I need a lot of help with these topics in general
Examples and Discussion Topics:
- You have been asked to replace CourseWeb with something that is nicer to use. Design the data structures to represent the following:
- a course
- assignments
- tests
- users
- Find and fix the data aggregation security problems in the code below:
class Values:
def __init__(self, vals):
self.__values = vals
def get_all(self):
return self.__values
def set_all(self, values):
self.__values = values
- Write a copy method for the
Values
class above.
- Write a
PositiveValues
class. This class stores a collection of positive numbers and must support the operations shown below. Be sure to address all data aggregation security concerns.
- a constructor that takes a collection of values and saves them into the object (non-positive numbers are converted to positive; all other non-positive values are ignored)
- a
get_all
method that returns the collection of positive values stored in the object
- a
set_all
method that takes a collection of values and saves them into the object (non-positive numbers are converted to positive; all other non-positive values are ignored)
- a
get
method that takes a position in the object's collection and returns the value at that position
- an
append
method that takes a value and:
- if it is a positive number, appends it to the object's collection
- if it is a negative number, converts it to positive and appends it to the object's collection
- if it is any other value, it raises a ValueError exception
- the
__len__
special method
Modules
Requests:
- These lectures were just overall where I become very lost in the course. I need a lot of help with these topics in general
Examples and Discussion Topics:
- Modules are source code files primarily with function and class definitions and are intended to be used in other programs (by other programmers)
sys.path
- An aside:
sys
module vs. os
module
Exception Handling
Requests:
- I have a hard time with the exception questions in which an exception is raised but not handled by the same part of the program. Those get very confusing and I spend too much time on those questions.
- When do I have to handle exceptions? Do I always have to? How exactly do I know when an exception should be handled/shouldn't?
- What does it mean to manually raise an exception, and when/how should I do it? (still pretty confused on this, especially).
- Exception propagation
Examples and Discussion Topics:
- What is the output of the following code snippet?
print('a')
try:
print('b')
raise ValueError
print('c')
except TypeError:
print('d')
except ValueError:
print('e')
print('f')
- What is the output of the following code snippet?
def functionA():
print('a')
raise ValueError
print('b')
def functionB():
print('c')
try:
functionA()
print('d')
except TypeError:
print('e')
print('f')
print('g')
try:
functionB()
print('h')
except ValueError:
print('i')
Dictionaries and Sets
Requests:
- review of difference between dictionaries and sets and examples of an application of each?
- No specific questions, just need more conceptual understanding and practice.
Examples and Discussion Topics:
- For each of the following cases, which data structure would you use (list, set, or dict)?
- Hold a collection of items that are hashable -- you don't want duplicates
- Hold a collection of items that are not hashable -- you don't want duplicates
- You have a collection of items and want to be able to look up values with a specific label (i.e. a specific label is associated with each value)
- You have a collection of items and you want to remove duplicates
- You have a collection of items and all you're interested in (ever) is whether values are in the collection or not
- You have a collection of items and each value has a specific label associated with it
- You want to hold a collection of items and do not care about order
Functions
No questions submitted.
Midterm Material
No questions submitted.