From 3d6d39b5ce7929bb5f4c8c6e7c8deeec03dc333a Mon Sep 17 00:00:00 2001 From: Adam Halka Date: Mon, 28 Oct 2024 18:19:25 +0100 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..c6ba650f 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: + return math.ceil(days / 7) + + @classmethod + def from_dict(cls, course_dict: dict) -> "OnlineCourse": + name = course_dict.get("name", "") + description = course_dict.get("description", "") + days = course_dict.get("days", 0) + + weeks = cls.days_to_weeks(days) + + return cls(name=name, description=description, weeks=weeks)