Quiz: What's Next — Cumulative Review

This is the final quiz. It draws from concepts across the entire book — a greatest hits of CS1. Test your understanding of the fundamentals that will carry you into every course, project, and career that comes next.

Target: 70% or higher. If you score below 70%, revisit the chapters referenced in the questions you missed.


Section 1: Foundations (Chapters 1-6)

1. Which of the following BEST describes computational thinking?

  • A) The ability to write code quickly in any programming language
  • B) A problem-solving framework based on decomposition, pattern recognition, abstraction, and algorithm design
  • C) The study of how computers process information at the hardware level
  • D) A method for designing user interfaces
Answer **B)** A problem-solving framework based on decomposition, pattern recognition, abstraction, and algorithm design. *Why B:* Computational thinking is the core framework introduced in [Chapter 1](../../part-01-getting-started/chapter-01-welcome-to-cs/index.md) and applied throughout the entire course. *Why not A:* Speed of coding is a mechanical skill, not computational thinking. *Why not C:* That's closer to computer architecture or computer engineering. *Why not D:* UI design is one application area, not a description of computational thinking. *Reference:* [Chapter 1](../../part-01-getting-started/chapter-01-welcome-to-cs/index.md), Section 1.2

2. What is the output of the following code?

x = 10
y = 3
print(x // y, x % y)
  • A) 3.33 1
  • B) 3 1
  • C) 3.0 1.0
  • D) 10 3
Answer **B)** `3 1` *Why B:* `//` is integer (floor) division (10 // 3 = 3), and `%` is modulo (10 % 3 = 1). Both operands are integers, so the results are integers. *Why not A:* `//` returns an integer (or float only if one operand is float), not a decimal. *Why not C:* Both operands are `int`, so results are `int`. *Why not D:* These are the operands, not the operation results. *Reference:* [Chapter 3](../../part-01-getting-started/chapter-03-variables-types-expressions/index.md), Section 3.3

3. A function that does one thing, does it well, and has a descriptive name follows which principle?

  • A) DRY (Don't Repeat Yourself)
  • B) Single Responsibility Principle
  • C) The Zen of Python
  • D) Both A and B
Answer **B)** Single Responsibility Principle. *Why B:* The Single Responsibility Principle (introduced formally in [Ch 16](../../part-05-object-oriented-programming/chapter-16-oop-design/index.md) but practiced from [Ch 6](../../part-02-control-flow/chapter-06-functions/index.md)) states that each function/class should have one reason to change — one job. *Why not A:* DRY is about avoiding code duplication, which is related but distinct from single responsibility. *Why not C:* The Zen of Python contains general design philosophies, not this specific principle. *Why not D:* While DRY is a good practice, the specific description (one thing, well, clear name) matches SRP most precisely. *Reference:* [Chapter 6](../../part-02-control-flow/chapter-06-functions/index.md), Section 6.2; [Chapter 16](../../part-05-object-oriented-programming/chapter-16-oop-design/index.md), Section 16.1

Section 2: Data Structures (Chapters 7-10)

4. Which data structure provides O(1) average-case lookup by key?

  • A) List
  • B) Tuple
  • C) Dictionary
  • D) String
Answer **C)** Dictionary. *Why C:* Dictionaries use hash tables internally, providing constant-time average-case key lookup. *Why not A:* List lookup by index is O(1), but searching for a value is O(n). *Why not B:* Same as lists — indexed access is O(1), but searching is O(n). *Why not D:* String character access by index is O(1), but searching for a substring is O(n). *Reference:* [Chapter 9](../../part-03-data/chapter-09-dictionaries-and-sets/index.md), Section 9.2

5. What is the key difference between a list and a tuple in Python?

  • A) Lists can contain any type; tuples cannot
  • B) Lists are mutable; tuples are immutable
  • C) Lists are ordered; tuples are unordered
  • D) Lists use square brackets; tuples use curly braces
Answer **B)** Lists are mutable; tuples are immutable. *Why B:* Mutability is the fundamental distinction. Lists can be modified after creation; tuples cannot. *Why not A:* Both lists and tuples can contain any type, including mixed types. *Why not C:* Both lists and tuples maintain insertion order. *Why not D:* Tuples use parentheses `()`, not curly braces `{}` (which are for dicts and sets). *Reference:* [Chapter 8](../../part-03-data/chapter-08-lists-and-tuples/index.md), Section 8.4

6. You need to read data from a JSON file and process it in Python. Which approach is correct?

  • A) open("data.json", "r") then json.load(file_object)
  • B) open("data.json", "r") then json.loads(file_object)
  • C) open("data.json", "w") then json.load(file_object)
  • D) open("data.json", "r") then file_object.read_json()
Answer **A)** `open("data.json", "r")` then `json.load(file_object)`. *Why A:* `json.load()` reads from a file object. You open the file in read mode ("r") and pass the file object to `json.load()`. *Why not B:* `json.loads()` (with an "s" for "string") parses a JSON string, not a file object. *Why not C:* Opening in write mode ("w") would erase the file contents, and reading wouldn't work. *Why not D:* File objects don't have a `read_json()` method. *Reference:* [Chapter 10](../../part-03-data/chapter-10-file-io/index.md), Section 10.4

Section 3: Robustness (Chapters 11-13)

7. What does EAFP stand for, and what approach does it favor?

  • A) "Errors Are For Processing" — use if-statements to prevent all errors
  • B) "Easier to Ask Forgiveness than Permission" — try the operation and handle exceptions if they occur
  • C) "Every Algorithm Fails Predictably" — test all edge cases before running
  • D) "Exceptions Allow Flexible Programming" — use exceptions for flow control
Answer **B)** "Easier to Ask Forgiveness than Permission" — try the operation and handle exceptions if they occur. *Why B:* EAFP is a Pythonic philosophy: rather than checking whether something is valid before doing it (LBYL — Look Before You Leap), you attempt the operation and catch exceptions. *Why not A:* This describes LBYL, the opposite of EAFP. *Why not D:* While Python does use exceptions, EAFP is about the approach to error handling, not using exceptions for general flow control (which is actually discouraged). *Reference:* [Chapter 11](../../part-04-building-robust-programs/chapter-11-error-handling/index.md), Section 11.3

8. In test-driven development (TDD), what is the correct order of steps?

  • A) Write code → Write tests → Refactor
  • B) Write tests → Write code → Refactor
  • C) Refactor → Write tests → Write code
  • D) Write code → Refactor → Write tests
Answer **B)** Write tests → Write code → Refactor (Red-Green-Refactor). *Why B:* TDD follows the Red-Green-Refactor cycle: write a failing test (Red), write the minimum code to pass it (Green), then improve the code (Refactor). *Why not A:* Writing code before tests is the traditional approach, not TDD. *Reference:* [Chapter 13](../../part-04-building-robust-programs/chapter-13-testing-and-debugging/index.md), Section 13.4

Section 4: OOP (Chapters 14-16)

9. What is polymorphism?

  • A) A class inheriting from multiple parent classes
  • B) Different objects responding to the same method call in different ways
  • C) Hiding internal data behind private attributes
  • D) A class that cannot be instantiated directly
Answer **B)** Different objects responding to the same method call in different ways. *Why B:* Polymorphism means "many forms." When you call `.display()` on a `DeadlineTask` and a `RecurringTask`, each responds with its own implementation — same interface, different behavior. *Why not A:* That's multiple inheritance. *Why not C:* That's encapsulation. *Why not D:* That's an abstract class. *Reference:* [Chapter 15](../../part-05-object-oriented-programming/chapter-15-inheritance-polymorphism/index.md), Section 15.3

10. When should you prefer composition over inheritance?

  • A) When the relationship is "has-a" rather than "is-a"
  • B) When you want to reuse code from a parent class
  • C) When you need polymorphic behavior
  • D) When you want to create abstract classes
Answer **A)** When the relationship is "has-a" rather than "is-a." *Why A:* A `Car` "has-a" `Engine` (composition). A `SportsCar` "is-a" `Car` (inheritance). Using inheritance for "has-a" relationships creates fragile, tightly coupled designs. *Why not B:* Code reuse can be achieved through both composition and inheritance, but composition is preferred for "has-a" relationships. *Why not C:* Polymorphism can be achieved with both inheritance and duck typing in Python. *Reference:* [Chapter 15](../../part-05-object-oriented-programming/chapter-15-inheritance-polymorphism/index.md), Section 15.5; [Chapter 16](../../part-05-object-oriented-programming/chapter-16-oop-design/index.md), Section 16.2

Section 5: Algorithms (Chapters 17-20)

11. What is the Big-O time complexity of searching for a value in an unsorted list of n elements?

  • A) O(1)
  • B) O(log n)
  • C) O(n)
  • D) O(n log n)
Answer **C)** O(n) — linear time. *Why C:* In the worst case, you must check every element (the target might be the last one, or not present at all). This is linear search. *Why not A:* O(1) would require knowing exactly where the element is (like dictionary lookup by key). *Why not B:* O(log n) requires a sorted collection (binary search). *Reference:* [Chapter 17](../../part-06-algorithms-and-data-structures/chapter-17-algorithms/index.md), Section 17.3; [Chapter 19](../../part-06-algorithms-and-data-structures/chapter-19-searching-and-sorting/index.md), Section 19.1

12. A recursive function without a proper base case will most likely result in:

  • A) An infinite loop
  • B) A RecursionError (maximum recursion depth exceeded)
  • C) A SyntaxError
  • D) The function returning None
Answer **B)** A `RecursionError` (maximum recursion depth exceeded). *Why B:* Python has a default recursion limit (typically 1,000). Without a base case, the function calls itself indefinitely until hitting this limit. *Why not A:* While conceptually similar to an infinite loop, the call stack fills up and Python raises `RecursionError` rather than looping forever. *Why not C:* `SyntaxError` is a compile-time error — the code is syntactically valid, it just has a logic flaw. *Reference:* [Chapter 18](../../part-06-algorithms-and-data-structures/chapter-18-recursion/index.md), Section 18.2

13. Which data structure uses LIFO (Last In, First Out) ordering?

  • A) Queue
  • B) Stack
  • C) List
  • D) Dictionary
Answer **B)** Stack. *Why B:* A stack follows Last In, First Out — the most recently added item is the first one removed (think of a stack of plates). *Why not A:* A queue uses FIFO (First In, First Out). *Why not C:* A list is a general-purpose sequence that supports both ends, but isn't defined by LIFO/FIFO behavior. *Why not D:* Dictionaries are key-value stores, not ordered by insertion for removal purposes. *Reference:* [Chapter 20](../../part-06-algorithms-and-data-structures/chapter-20-stacks-queues-beyond/index.md), Section 20.1

Section 6: Real-World Python (Chapters 21-24)

14. What does a 200 HTTP status code mean when making an API request?

  • A) The server encountered an error
  • B) The resource was not found
  • C) The request was successful
  • D) The request was redirected
Answer **C)** The request was successful. *Why C:* Status code 200 means "OK" — the server successfully processed the request and returned the expected response. *Why not A:* Server errors are 5xx codes (e.g., 500 Internal Server Error). *Why not B:* "Not found" is 404. *Why not D:* Redirects are 3xx codes (e.g., 301, 302). *Reference:* [Chapter 21](../../part-07-real-world-python/chapter-21-working-with-data/index.md), Section 21.2

15. Which of the following is a valid reason to use a virtual environment for a Python project?

  • A) To make Python code run faster
  • B) To isolate project dependencies and avoid version conflicts between projects
  • C) To encrypt your source code
  • D) To automatically test your code
Answer **B)** To isolate project dependencies and avoid version conflicts between projects. *Why B:* Virtual environments create isolated Python environments so that Project A can use `requests 2.28` while Project B uses `requests 2.31` without conflict. *Why not A:* Virtual environments don't affect execution speed. *Why not C:* Virtual environments don't provide encryption. *Why not D:* Testing is done with tools like pytest, not virtual environments. *Reference:* [Chapter 23](../../part-07-real-world-python/chapter-23-libraries-and-environments/index.md), Section 23.1

Section 7: Professional Practice and What's Next (Chapters 25-27)

16. What is the purpose of a Git commit?

  • A) To upload your code to the internet
  • B) To save a snapshot of your project's current state with a descriptive message
  • C) To merge two branches together
  • D) To delete files you no longer need
Answer **B)** To save a snapshot of your project's current state with a descriptive message. *Why B:* A commit records a point in your project's history that you can return to later. The message explains what changed and why. *Why not A:* Uploading to a remote is `git push`, not `git commit`. *Why not C:* Merging is `git merge`. *Why not D:* Deleting files is a separate operation; commits record changes, they don't inherently delete. *Reference:* [Chapter 25](../chapter-25-version-control-git/index.md), Section 25.2

17. According to this chapter, why is understanding fundamentals important even when AI can generate code?

  • A) AI-generated code is always wrong
  • B) AI will be banned from professional settings
  • C) Fundamentals allow you to evaluate, debug, and improve AI-generated code
  • D) AI tools only work in Python, not other languages
Answer **C)** Fundamentals allow you to evaluate, debug, and improve AI-generated code. *Why C:* AI tools amplify your abilities — but only if you have abilities to amplify. Without understanding data structures, algorithms, and design, you can't tell if AI-generated code is correct, efficient, or secure. *Why not A:* AI-generated code is often partially correct, which makes evaluation even more important. *Why not B:* AI tools are increasingly adopted in professional settings. *Why not D:* AI tools work across many languages. *Reference:* Section 27.4

18. Which of the following is NOT mentioned as a career pathway in computer science?

  • A) Cybersecurity
  • B) Graphic design
  • C) Data science
  • D) DevOps
Answer **B)** Graphic design. *Why B:* While graphic design intersects with tech, it was not listed as a CS career pathway in Section 27.3. The listed pathways are: web development, mobile development, data science, ML/AI, cybersecurity, game development, DevOps, and research. *Reference:* Section 27.3

Section 8: Synthesis

19. A student has a list of 1,000,000 sorted integers and needs to check whether a specific number is in the list. Which approach is most appropriate?

  • A) Linear search — check each element one by one
  • B) Binary search — repeatedly divide the search space in half
  • C) Convert the list to a dictionary and check membership
  • D) Sort the list first, then use linear search
Answer **B)** Binary search — repeatedly divide the search space in half. *Why B:* The list is already sorted, so binary search gives O(log n) performance — about 20 comparisons for 1,000,000 elements versus up to 1,000,000 for linear search. *Why not A:* Linear search is O(n), which is wasteful when the data is already sorted. *Why not C:* Converting to a dictionary is O(n) and uses significant extra memory. Binary search achieves the goal without extra space. *Why not D:* The list is already sorted — sorting it again is wasted work, and linear search after sorting still gives O(n). *Reference:* [Chapter 19](../../part-06-algorithms-and-data-structures/chapter-19-searching-and-sorting/index.md), Section 19.2

20. Which recurring theme from this textbook is BEST summarized by the statement: "A program that crashes with a clear error message is better than a program that silently produces wrong results"?

  • A) Computational thinking is a superpower
  • B) Errors are information, not failures
  • C) Reading code is as important as writing it
  • D) Many ways to solve every problem
Answer **B)** Errors are information, not failures. *Why B:* This theme emphasizes that errors and exceptions are valuable feedback. A clear error message tells you exactly what went wrong and where. Silent failures — where the program runs but produces incorrect results — are far more dangerous because they hide problems. *Why not A:* Computational thinking is about problem-solving frameworks, not error handling. *Why not C:* Code reading is about understanding existing code, not about error messages. *Why not D:* Multiple solutions is about design trade-offs, not error handling. *Reference:* Recurring theme across Chapters 2, 5, 11, 13, 18, 22

Scoring

Score Recommendation
18-20 Excellent! You have a strong command of CS1 fundamentals. You're well-prepared for CS2 and beyond.
14-17 Good foundation. Review the chapters referenced in any questions you missed.
10-13 Revisit Parts III-VI (Data, OOP, Algorithms). Consider working through additional exercises.
Below 10 Spend time reviewing earlier chapters before moving to CS2. Focus on the concepts you rated lowest in the self-assessment.

Regardless of your score, remember: this quiz tests recall, not capability. Your ability to build TaskFlow across 25 iterations is a stronger indicator of your skills than any multiple-choice quiz.