Final Exam Review

Survey Results

Classes

Requests:

Examples and Discussion Topics:

  1. You have been asked to replace CourseWeb with something that is nicer to use. Design the data structures to represent the following:
  2. 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
            
  3. Write a copy method for the Values class above.
  4. 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.

Modules

Requests:

Examples and Discussion Topics:

  1. Modules are source code files primarily with function and class definitions and are intended to be used in other programs (by other programmers)
  2. sys.path
  3. An aside: sys module vs. os module

Exception Handling

Requests:

Examples and Discussion Topics:

  1. 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')
  2. 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:

Examples and Discussion Topics:

  1. For each of the following cases, which data structure would you use (list, set, or dict)?

Functions

No questions submitted.

Midterm Material

No questions submitted.

  Daily Schedule