From f85b40f1a685bf2875f9e56b91a5372c7483ea52 Mon Sep 17 00:00:00 2001 From: user Date: Sat, 14 Dec 2024 18:53:37 +0200 Subject: [PATCH 1/2] My solution --- app/main.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index a740cca7..2c1dee1d 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,14 @@ 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) -> "OnlineCourse": + return cls(course_dict["name"], course_dict['description'], OnlineCourse.days_to_weeks(course_dict["days"])) From f1b48a92d1de21b0d7d6f76172403ba89bc74382 Mon Sep 17 00:00:00 2001 From: user Date: Sat, 14 Dec 2024 18:56:33 +0200 Subject: [PATCH 2/2] My solution 2 --- app/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 2c1dee1d..a3823cf8 100644 --- a/app/main.py +++ b/app/main.py @@ -10,5 +10,9 @@ def days_to_weeks(days: int) -> int: return (days + 6) // 7 @classmethod - def from_dict(cls, course_dict) -> "OnlineCourse": - return cls(course_dict["name"], course_dict['description'], OnlineCourse.days_to_weeks(course_dict["days"])) + def from_dict(cls, course_dict: dict) -> "OnlineCourse": + return cls( + course_dict["name"], + course_dict["description"], + OnlineCourse.days_to_weeks(course_dict["days"]) + )