From d0b4a80d930e74ea32bdab6c751862b28993b5b6 Mon Sep 17 00:00:00 2001 From: yevpy Date: Wed, 20 Nov 2024 00:33:56 +0200 Subject: [PATCH] Solution --- app/main.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index a740cca7..c468332e 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,22 @@ +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: + weeks = math.ceil(days / 7) + + return weeks + + @classmethod + def from_dict(cls, course_dict: dict) -> "OnlineCourse": + name = course_dict["name"] + description = course_dict["description"] + days = course_dict["days"] + + return cls(name, description, cls.days_to_weeks(days))