From f95c88617c993ae29d6ee5d38a23e282bdf22612 Mon Sep 17 00:00:00 2001 From: Ron Phillips Date: Sun, 12 Jan 2025 12:50:37 -0600 Subject: [PATCH 1/2] Solution --- app/main.py | 22 ++++++++++++++++++++-- requirements.txt | 10 +++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app/main.py b/app/main.py index a740cca7..29627b7a 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,21 @@ +from math import ceil + + class OnlineCourse: - # write your code here - pass + + def __init__(self, name: str, description: str, weeks: int): + 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"], + OnlineCourse.days_to_weeks(course_dict["days"]) + ) diff --git a/requirements.txt b/requirements.txt index 3f202d6e..68982504 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -flake8==5.0.4 -flake8-annotations==2.9.1 -flake8-quotes==3.3.1 -flake8-variables-names==0.0.5 +flake8==7.1.1 +flake8-annotations==3.1.1 +flake8-quotes==3.4.0 +flake8-variables-names==0.0.6 pep8-naming==0.13.2 -pytest==7.1.3 +pytest==7.1.3 \ No newline at end of file From d14a8ba5036d8b78702f1baf4b2e923cd5f2ba6f Mon Sep 17 00:00:00 2001 From: Ron Phillips Date: Sun, 12 Jan 2025 12:53:43 -0600 Subject: [PATCH 2/2] Solution - Flake8 --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 29627b7a..8b57ae29 100644 --- a/app/main.py +++ b/app/main.py @@ -3,7 +3,7 @@ class OnlineCourse: - def __init__(self, name: str, description: str, weeks: int): + def __init__(self, name: str, description: str, weeks: int) -> None: self.name = name self.description = description self.weeks = weeks