0% found this document useful (0 votes)
4 views2 pages

Task Management and Statistics Tool

Uploaded by

labom73814
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Task Management and Statistics Tool

Uploaded by

labom73814
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import random

import time
from datetime import datetime

class Task:
def __init__(self, name, priority):
[Link] = name
[Link] = priority
[Link] = [Link]()
[Link] = "pending"

def run(self):
[Link] = "running"
[Link](0.01)
[Link] = "done"

def info(self):
return f"{[Link]} | prio={[Link]} | {[Link]} |
{[Link]}"

class TaskManager:
def __init__(self):
[Link] = []

def add(self, task):


[Link](task)

def run_all(self):
for t in sorted([Link], key=lambda x: [Link], reverse=True):
[Link]()

def report(self):
rep = "--- RAPORT ZADAN ---\n"
for t in [Link]:
rep += [Link]() + "\n"
return rep

def random_tasks(n):
tm = TaskManager()
for i in range(n):
name = f"task_{i}_{[Link](100,999)}"
prio = [Link](1, 10)
[Link](Task(name, prio))
return tm

def compute_stats(tasks):
priolist = [[Link] for t in tasks]
s = sum(priolist)
avg = s / len(priolist)
mx = max(priolist)
mn = min(priolist)
return {"sum": s, "avg": avg, "max": mx, "min": mn}

def ascii_bar(value, length=40):


filled = int((value / 10) * length)
return "[" + "#" * filled + "-" * (length - filled) + "]"

def stats_report(stats):
r = "\n--- STATYSTYKI PRIORYTETÓW ---\n"
r += f"Suma: {stats['sum']}\n"
r += f"Średnia: {stats['avg']:.2f}\n"
r += f"Max: {stats['max']} {ascii_bar(stats['max'])}\n"
r += f"Min: {stats['min']} {ascii_bar(stats['min'])}\n"
return r

def main():
print("Generuję

You might also like