From f0c065168fe926124e7ad0ceb4ad982023203778 Mon Sep 17 00:00:00 2001 From: Yaroslav Kalugin Date: Wed, 18 Dec 2024 19:51:39 +0200 Subject: [PATCH] Solution --- app/main.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index a740cca7..482554d8 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,19 @@ 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 + 6) // 7 + + @classmethod + def from_dict(cls, course_dict: str) -> "OnlineCourse": + name = course_dict["name"] + description = course_dict["description"] + weeks = cls.days_to_weeks(course_dict["days"]) + return cls(name, description, weeks)