From 583419bd0f61ce61cca953c294dd99ed5ca052bf Mon Sep 17 00:00:00 2001 From: Dell Date: Fri, 11 Oct 2024 00:11:28 +0300 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..5e08f481 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: + week = 0 + while days >= 1: + week += 1 + days = days - 7 + return week + + @classmethod + def from_dict(cls, cours_dict: dict) -> "OnlineCourse": + return cls( + name=cours_dict["name"], + description=cours_dict["description"], + weeks=cls.days_to_weeks(cours_dict["days"]) + )