CMSI 1010
Exam 2 Preparation

When

Wednesday, November 18, 2025, last 60 minutes of class.

Scope

Labs 8–13, and all the associated readings in the Further Study sections.

Ground Rules

In person, on paper.

Preparation Checklist

Do each of the following to maximize your preparation:

Were you able to check off every box?

An Outline of Course Content For This Exam

The fact that active recall is better for acquiring long-term knowledge does not mean that outlines and concept maps are not useful. Learners should use multiple techniques—think “both and” rather than “either or.”

Recursion
    base case
    recursive case
    often you don’t need or want it, if a simple loop will do
    if recursion is multi-way, it tends to shine more
    (but be careful not to “overlap”—you will learn why in CMSI 2120)
    recursion in nature and art (Fractals)
    recursive structures

Classes
    often better than dictionaries when representing ”things”
    class definitions
    __init__() method
    self parameter
    attributes
    methods
    Variables are necessary for sharing!
    Dataclass are usually better! (__init__() is auto-generated)
    Have to use the @dataclass decorator
    Have to import dataclass from the dataclasses module
    how to make objects immutable (and why it matters)
    You can validate with __post_init__()

RGB Colors
    RGB tuples
    (0, 0, 0) is black
    (255, 255, 255) is white
    (255, 0, 0) is red
    (0, 255, 0) is green
    (0, 0, 255) is blue
    other colors are combinations of red, green, and blue

Additional Python Programming Techniques
    conditional expressions
    integer division with //
    why single recursion isn't always great
    why multi-way recursion can be more powerful
    raising exceptions
    the various kinds of built-in exceptions
    == vs. is
    references
    variable vs. objects
    try and except for error handling
    command line arguments with sys.argv
    converting strings to integers with int()
    input validation
    list comprehensions

Format of the Exam

The exam is closed book, closed device, on paper, but you can bring in two sheets of paper with notes.

About the Problems

There will be 20 questions of the multiple choice, multiple select, fill-in-the-blank, and short answer variety. Here are the topic areas for each problem (and some actual questions too):

  1. What happens if you call a recursive function without a base case?
  2. Which of the following recursive functions are accurate implementations of the "halfsies" function?
  3. What does the recursive function mystery(a) do? (That is, you will be given a function called mystery and you need to choose the answer that correctly says what the function does.)
  4. Number of moves in Tower of Hanoi for a given number of disks
  5. Given a recursive function, determine its output for a specific input
  6. Which of the following are true about recursion?
  7. Write a recursive function to count the number of vowels in a string
  8. Person class without __str__ (what happens when you try to print an instance?)
  9. Choose the right explanation for a particular call of is_sibling_of
  10. Python method call syntax...what is it a shorthand for?
  11. Syntax questions about dataclasses
  12. When is a dataclass’s __post_init__() method called?
  13. Choose which of the following statements are true about a particular dataclass definition (of the Card class)
  14. Write a dataclass definition for an RGB color
  15. Match colors to their RGB tuples
  16. Which of the following are legal RGB tuples?
  17. Choose the right output for code with try and except
  18. Choose between TypeError and ValueError for various card constructions
  19. How to get a command line argument and interpret it as an integer
  20. Write a complete Python program that prints the sum of its command line arguments, treated as integers