From c6a8929860ed20224eda4e52bc698c137c36ed89 Mon Sep 17 00:00:00 2001 From: Ostrovka Mykola Date: Tue, 3 Dec 2024 20:34:48 +0100 Subject: [PATCH] Solution --- app/main.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index a740cca7..fb0b3224 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,24 @@ +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: + if days >= 7: + if days % 7 > 0: + return (days // 7) + 1 + return days // 7 + return 1 + + @classmethod + def from_dict(cls, course_dict: dict) -> OnlineCourse: + return cls( + course_dict["name"], + course_dict["description"], + cls.days_to_weeks(course_dict["days"]) + )