Skip to content

Commit

Permalink
adding solution to task 'online-course
Browse files Browse the repository at this point in the history
  • Loading branch information
Annolel committed Nov 27, 2024
1 parent 8ac761e commit 42626e2
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
import math
from typing import Any


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 math.ceil(days / 7)

@classmethod
def from_dict(cls, course_dict: dict) -> Any:
tmp_weeks = {"weeks": cls.days_to_weeks(course_dict["days"])}
del course_dict["days"]
course_dict.update(tmp_weeks)
return cls(
course_dict["name"],
course_dict["description"],
course_dict["weeks"]
)

0 comments on commit 42626e2

Please sign in to comment.