Skip to content

Commit 975d9ac

Browse files
author
qwik zgheib mossad bashit
committed
feat: #25 - py
1 parent 949296f commit 975d9ac

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import logging
2+
3+
# -- exercise
4+
logging.basicConfig(level=logging.DEBUG)
5+
6+
# Log messages with different severity levels
7+
logging.debug("This is a debug message")
8+
logging.info("This is an info message")
9+
logging.warning("This is a warning message")
10+
logging.error("This is an error message")
11+
logging.critical("This is a critical message")
12+
13+
14+
# -- extra challenge
15+
class TaskManager:
16+
def __init__(self):
17+
self.tasks = []
18+
19+
def add_task(self, name, description):
20+
task = {"name": name, "description": description}
21+
self.tasks.append(task)
22+
logging.info(f"Task '{name}' added")
23+
24+
def delete_task(self, name):
25+
for task in self.tasks:
26+
if task["name"] == name:
27+
self.tasks.remove(task)
28+
logging.info(f"Task '{name}' deleted")
29+
break
30+
else:
31+
logging.warning(f"Task '{name}' not found")
32+
33+
def list_tasks(self):
34+
for task in self.tasks:
35+
logging.info(f"Task: {task['name']}, Description: {task['description']}")
36+
37+
38+
task_manager = TaskManager()
39+
40+
task_manager.add_task("Task 1", "Description 1")
41+
task_manager.add_task("Task 2", "Description 2")
42+
43+
task_manager.delete_task("Task 1")
44+
45+
task_manager.list_tasks()

0 commit comments

Comments
 (0)