From 08c45311b87baec8a71dfb1c9846dd83f8ff5dc6 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Fri, 13 Dec 2024 17:18:29 +0200 Subject: [PATCH] 'Solution' --- app/main.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index a740cca7..dd68a003 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,21 @@ 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: + our_weeks = days // 7 + if days % 7 != 0: + our_weeks += 1 + return our_weeks + + @classmethod + def from_dict(cls, dict_in: dict) -> "OnlineCourse": + our_online_course = cls( + dict_in["name"], + dict_in["description"], + cls.days_to_weeks(dict_in["days"]) + ) + return our_online_course