From 5cfb0602133e28c95d214ee0a8500877c39378af Mon Sep 17 00:00:00 2001 From: Bohdana Salabai Date: Mon, 23 Dec 2024 20:49:32 +0100 Subject: [PATCH] Solution --- app/main.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index a740cca7..06399e91 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,20 @@ +from __future__ import annotations +import math + + class OnlineCourse: - # write your code here - pass + def __init__(self, name: str, description: str, weeks: int) -> None: + self.name = name + self.description = description + self.weeks = weeks + + @staticmethod + def days_to_weeks(days: int) -> int: + return math.ceil(days / 7) + + @classmethod + def from_dict(cls, course_dict: dict) -> OnlineCourse: + name = course_dict["name"] + description = course_dict["description"] + weeks = cls.days_to_weeks(course_dict["days"]) + return cls(name, description, weeks)