From ce7df26bc6bf54bf335dded6ffb4fe378f07ba38 Mon Sep 17 00:00:00 2001 From: Volodymyr Povroznyk Date: Fri, 11 Oct 2024 18:17:32 +0300 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..af65524c 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,20 @@ +from __future__ import annotations + + 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 days // 7 if days % 7 == 0 else (days // 7) + 1 + + @classmethod + def from_dict(cls, cource_dict: dict) -> OnlineCourse: + return cls( + name=cource_dict["name"], + description=cource_dict["description"], + weeks=cls.days_to_weeks(cource_dict["days"]) + )