From 7bbc0beb2c7e779ac14cfda378c561a2d311060b Mon Sep 17 00:00:00 2001 From: Yura Chornyi Date: Fri, 10 Jan 2025 01:03:02 +0200 Subject: [PATCH] Solution - online course --- app/main.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index a740cca7..f38cb819 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,22 @@ +from __future__ import annotations +from math import ceil + + 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 ceil(days / 7) + + @classmethod + def from_dict(cls, course_dict: dict) -> OnlineCourse: + return cls( + course_dict["name"], + course_dict["description"], + cls.days_to_weeks(course_dict["days"]) + )