Implement a Python To-Do Task Manager Class with CRUD and Status Rules
Company: Cisco
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: easy
Interview Round: Onsite
Write a Python class that manages a to-do list of tasks. It must support the four CRUD operations: create a task, read one task or a list of tasks, update a task, and delete a task. Every task has a status, which is one of `new`, `pending` or `resolved`.
```hint Model the status
Decide how to represent the three statuses so that a typo such as `"resloved"` can never end up stored on a task.
```
```hint Decide the failure behavior first
Before writing the methods, decide what each one does when the task ID does not exist or the input is invalid, and apply that choice consistently.
```
### Constraints and Clarifications
- Assume in-memory storage is enough unless the interviewer asks for persistence.
- Assume a newly created task starts with the status `new`.
### Clarifying Questions
- Which fields does a task have besides a title and a status: a description, a due date, timestamps, an owner?
- Are any status changes forbidden, for example moving a `resolved` task back to `new`?
- How are task IDs generated, and must an ID stay unused after its task is deleted?
- Should an operation on a missing task raise an exception, or return a value such as `None` or `False`?
- Is listing with a filter needed, for example all `pending` tasks?
- Must the class be safe to use from several threads?
### What a Strong Answer Covers
- A clear task model with a constrained status type and validated fields
- Complete, consistent CRUD methods with defined behavior for missing IDs and invalid input
- A deliberate status-transition policy, either explicitly permissive or enforced in one place
- Efficient lookups and filtering, and returned objects that callers cannot use to corrupt the manager's state
- A design that is easy to test, for example an injectable clock
### Follow-up Questions
- How would you test this class with pytest, and which fixtures would you write?
- How would you add persistence to SQLite or a file without changing the public interface?
- How would you make the class safe to use from several threads?
- How would you support undoing the last operation?
Overview: A Python coding question asking for a to-do task manager class with create, read, update, and delete operations, where every task has a status of new, pending, or resolved. It tests data modeling, input validation, status transition rules, error handling for missing tasks, and testable class design.
Read the full Cisco Software Engineer interview experience this question came from