Open bhashkarmishra14 opened 1 year ago
code - class ToDoList: def init(self): self.tasks = []
def add_task(self, task):
self.tasks.append({"task": task, "completed": False})
def mark_completed(self, task_index):
if 0 <= task_index < len(self.tasks):
self.tasks[task_index]["completed"] = True
else:
print("Invalid task index.")
def display_tasks(self):
if not self.tasks:
print("No tasks in the list.")
else:
for index, task in enumerate(self.tasks):
status = "✓" if task["completed"] else " "
print(f"{index + 1}. [{status}] {task['task']}")
def main(): todo_list = ToDoList()
while True:
print("\n==== To-Do List ====")
print("1. Add Task")
print("2. Mark Task as Completed")
print("3. Display Tasks")
print("4. Quit")
choice = input("Enter your choice: ")
if choice == "1":
task = input("Enter the task: ")
todo_list.add_task(task)
print("Task added successfully.")
elif choice == "2":
todo_list.display_tasks()
task_index = int(input("Enter the task number to mark as completed: ")) - 1
todo_list.mark_completed(task_index)
elif choice == "3":
todo_list.display_tasks()
elif choice == "4":
print("Goodbye!")
break
else:
print("Invalid choice. Please choose a valid option.")
if name == "main": main()
A To-Do List Application using Python is a program that allows users to manage and organize their tasks or to-do items. It provides a convenient way to keep track of tasks that need to be completed, prioritize them, and mark them as done. The application can be implemented using different interfaces, such as command-line, graphical user interface (GUI), or web-based interface. Here's a description of a basic To-Do List Application:
Features:
Add Tasks: Users can add new tasks to the to-do list. Tasks can be entered through a text input field or a command-line prompt.
View Tasks: The application displays the list of tasks in a readable format. Each task is usually accompanied by a unique identifier, task description, and its current status (e.g., incomplete or completed).
Mark as Complete: Users can mark tasks as complete when they are finished. This action helps users keep track of their progress and easily identify which tasks are pending.
Delete Tasks: The ability to remove tasks from the list is a common feature. Users can delete tasks that are no longer relevant or needed.
Priority and Categorization: Advanced to-do list applications may allow users to assign priorities (e.g., high, medium, low) or categorize tasks (e.g., work, personal, shopping) for better organization.
Sorting and Filtering: Sorting tasks by different criteria (e.g., due date, priority) and applying filters (e.g., show only incomplete tasks) can help users focus on specific tasks.
Persistence: To ensure that tasks are not lost when the application is closed, many to-do list applications store tasks in a persistent storage system, such as a local file or a database.
User-Friendly Interface: GUI-based applications provide a visually appealing interface where users can interact with the to-do list using buttons, checkboxes, and input fields. Command-line applications offer a text-based interface where users enter commands or select options.
Usage:
Users can employ the To-Do List Application for various purposes, such as managing work-related tasks, tracking assignments, organizing personal chores, setting reminders for important activities, and planning projects.
Benefits:
Organization: The application helps users keep their tasks organized in one central location, preventing important tasks from being forgotten.
Productivity: By visualizing tasks and their statuses, users can prioritize and manage their time more effectively.
Focus: Users can focus on completing tasks without the mental burden of remembering everything they need to do.
Progress Tracking: Users can track their progress by marking completed tasks, which provides a sense of accomplishment.
Time Management: The application aids in planning tasks over days, weeks, or months, facilitating better time management.
Customization: Users can tailor the application to their needs by adding, modifying, or removing tasks as required.
Overall, a To-Do List Application using Python simplifies task management and contributes to better organization and productivity in various aspects of life.