Task Breakdown

Đang mở
#2,382 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
cli, documentation

Hướng nghiên cứu

Bắt đầu với cấu trúc todo_app được yêu cầu: todo.py, tasks.json và README.md. Xác minh thiết lập Python bằng python --version, sau đó chạy python todo.py trong khi kiểm tra hành vi thêm, xem, hoàn thành, xóa, thoát và lưu trữ. Được xem là hoàn tất khi các tính năng CLI được mô tả hoạt động và README ghi lại thông tin về ứng dụng cũng như cách sử dụng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

1)Set Up Your Environment:

Ensure Python is installed on your machine.
You can check this by running:
bash
Copy code
python --version
Project Structure:

Create a directory for the project named todo_app.

Inside it, create the following files:

todo.py: This will contain the main application logic.
tasks.json: This will store the tasks in JSON format.
README.md: Add documentation.
Your file structure should look like this:

bash
Copy code
/todo_app
├── todo.py # Main application logic
├── tasks.json # File to store tasks
└── README.md # Documentation
Implement Core Features:

2)Task Class:

Define a Task class that represents individual tasks in the app. This class should handle the creation of tasks and the ability to mark them as completed:
python
Copy code
class Task:
def init(self, title, description, category):
self.title = title
self.description = description
self.category = category
self.completed = False

def mark_completed(self):
    self.completed = True

3)File Handling:

Use Python's json module to store tasks in a tasks.json file. This allows persistence across runs of the application.

Code to save tasks:

python
Copy code
import json

def save_tasks(tasks):
with open('tasks.json', 'w') as f:
json.dump([task.dict for task in tasks], f)
Code to load tasks:

python
Copy code
def load_tasks():
try:
with open('tasks.json', 'r') as f:
return [Task(**data) for data in json.load(f)]
except FileNotFoundError:
return []
4)User Interaction:

Implement a simple command-line interface (CLI) to interact with the user. This will include options to add a task, view tasks, mark tasks as completed, delete tasks, and exit the application.
Here's a sample implementation of the main() function:

python
Copy code
def main():
tasks = load_tasks()
while True:
print("1. Add Task")
print("2. View Tasks")
print("3. Mark Task Completed")
print("4. Delete Task")
print("5. Exit")

    choice = input("Choose an option: ")

    if choice == '1':
        # Add task
        title = input("Title: ")
        description = input("Description: ")
        category = input("Category: ")
        tasks.append(Task(title, description, category))
    elif choice == '2':
        # View tasks
        for idx, task in enumerate(tasks, 1):
            status = "Completed" if task.completed else "Incomplete"
            print(f"{idx}. {task.title} - {status}")
    elif choice == '3':
        # Mark task as completed
        task_num = int(input("Enter task number to mark as completed: "))
        tasks[task_num - 1].mark_completed()
    elif choice == '4':
        # Delete task
        task_num = int(input("Enter task number to delete: "))
        del tasks[task_num - 1]
    elif choice == '5':
        save_tasks(tasks)
        break

5)Testing and Documentation:

Thoroughly test your app by adding, viewing, marking, and deleting tasks.
Document the purpose of the app and how to use it in the README.md file.
README.md Example:
markdown
Copy code

To-Do App

A simple command-line To-Do list manager built with Python.

Features:

  • Add tasks with titles, descriptions, and categories.
  • View tasks and their completion status.
  • Mark tasks as completed.
  • Delete tasks.
  • Save tasks to a JSON file for persistence.

Usage:

  1. Run the application:
    python todo.py
    

Follow the on-screen instructions to manage your tasks.
sql
Copy code

Ngôn ngữ chính
Python
Star
35.4k
Fork
12.9k
Merge trung bình
2 giờ 37 phút
Pull request đã merge (30 ngày)
1

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của geekcomputers/Python

Tất cả issue của geekcomputers/Python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.