The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Create a task prioritization script

Here’s a simple Python script for task prioritization based on urgency and importance. It uses a simple matrix to prioritize tasks, where each task is rated on a scale from 1 (low) to 5 (high) for both urgency and importance. The script will output tasks sorted by priority.

python
# Task Prioritization Script class Task: def __init__(self, name, urgency, importance): self.name = name self.urgency = urgency self.importance = importance self.priority_score = self.urgency + self.importance # Calculate priority score def __repr__(self): return f"Task(name='{self.name}', urgency={self.urgency}, importance={self.importance}, priority_score={self.priority_score})" def sort_tasks_by_priority(tasks): return sorted(tasks, key=lambda task: task.priority_score, reverse=True) def add_task(tasks, name, urgency, importance): task = Task(name, urgency, importance) tasks.append(task) def display_tasks(tasks): print(f"{'Task Name':<25}{'Urgency':<10}{'Importance':<10}{'Priority Score'}") print('-' * 55) for task in tasks: print(f"{task.name:<25}{task.urgency:<10}{task.importance:<10}{task.priority_score}") # Example Usage if __name__ == "__main__": tasks = [] # Add some tasks with urgency and importance ratings (1 to 5 scale) add_task(tasks, "Finish report", 5, 4) add_task(tasks, "Check emails", 3, 2) add_task(tasks, "Prepare presentation", 4, 5) add_task(tasks, "Plan vacation", 1, 3) # Sort tasks by priority sorted_tasks = sort_tasks_by_priority(tasks) # Display sorted tasks display_tasks(sorted_tasks)

Explanation:

  • Each task has a name, urgency, and importance rating (on a 1-5 scale).

  • The priority_score is calculated by adding urgency and importance.

  • Tasks are then sorted by the priority score in descending order, where a higher score means higher priority.

  • The display_tasks function prints the list of tasks along with their urgency, importance, and priority score.

Sample Output:

pgsql
Task Name Urgency Importance Priority Score ------------------------------------------------------- Finish report 5 4 9 Prepare presentation 4 5 9 Check emails 3 2 5 Plan vacation 1 3 4

This script can easily be extended, e.g., by adding deadlines, or even creating a user interface to interact with the tasks dynamically.

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About