Build a command-line task manager that supports:
- Creating, editing, and completing tasks
- Organizing tasks by tags (using dictionaries)
- Saving and loading task lists (JSON or pickle)
- Logging user actions
- Full test suite using
pytestorunittest
- Object-Oriented Design
- Class
Task: represents a single task (title, deadline, tags, status) - Class
TaskManager: holds tasks in a dict (task_id→Task) - Optional class
CLIor just procedural CLI logic
- Class
- Use of
dict- Internal storage:
self.tasks: Dict[int, Task] - Tags:
Dict[str, List[int]]mapping tags to task IDs
- Internal storage:
- Testing with
pytest- Unit tests for
Taskbehavior (e.g. mark as complete) - Unit tests for
TaskManager(e.g. add, delete, find, tag filter)
- Unit tests for
- Logging
- Log every action (e.g. task created, completed, deleted)
- Write logs to a file with timestamped entries
- Persistence (Bonus)
- Save/load tasks as JSON or pickle
- Command to export/import from file
- prioritize tasks
Implement a command-line Tic Tac Toe game in Python with:
- A clear object-oriented design
- Automated unit tests
- Logging of moves and game results
- Use of dictionaries for game state or players
The program should support:
- Two human players alternating turns
- Game board display and user input
- Win/draw detection
- Logging of all moves and outcomes
Implement at least the following classes:
Game: main controllerBoard: tracks the 3×3 gridPlayer: represents a player (name, symbol)- (Optional)
MoveorLoggerclass for logging actions
-
Use a dictionary to represent the grid:
python CopyEdit self.grid = {(0, 0): None, (0, 1): 'X', ...} -
Or a list of lists is allowed if well-encapsulated
- Simple CLI interaction:
- Print board
- Prompt player for moves (e.g.,
Enter row,col:)
- Reject invalid moves (occupied cells or out of bounds)
- Detect win or draw after every move
- Log each move with timestamp to
game.log - Log game start and result
- Create a test file (e.g.
test_game.py) with:- Tests for win detection
- Tests for draw detection
- Tests for move validation
- Use
pytestorunittest
- Add simple AI (
random,block-win) - Replay log file to reconstruct game
- Save/load game state to file
Implement a simplified command-line Minesweeper game in Python. The player reveals cells in a hidden grid, trying to avoid mines. The game should be structured using object-oriented principles, with testable components and logging.
Implement at least the following classes:
Game: orchestrates the game loopBoard: manages the grid, mine placement, and displayCell: represents an individual cell (state: revealed, flagged, mined, adjacent mine count)- (Optional)
PlayerAction,Logger, orConfigclasses
Use a dictionary for the internal grid:
self.cells = {(x, y): Cell(), ...}Where x and y are coordinates on the board (e.g., 9×9 or 10×10).
or a list of lists
- Prompt the player for input like
reveal 3,5orflag 2,1 - Reveal logic should support recursive uncovering of 0-adjacent-mine cells
- Display the board (concealed cells as
·, flagged asF, revealed numbers)
- Player loses by revealing a mine
- Player wins when all non-mine cells are revealed
- Flags are optional for solving but helpful
- Log all user actions (
reveal,flag) with timestamps - Log game start, victory, or defeat in
minesweeper.log
Write a test file (e.g. test_board.py) with:
- Unit tests for mine placement
- Tests for adjacent mine counting
- Tests for reveal propagation
- Tests for win/loss detection
Use
pytestorunittest.
- Add a simple timer and high score logging
- Support multiple board sizes
- Save/load game state to a file