-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ac761e
commit e2d7858
Showing
1 changed file
with
21 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
import math | ||
|
||
|
||
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) -> "OnlineCourse.weeks": | ||
return math.ceil(days / 7) | ||
|
||
@classmethod | ||
def from_dict(cls, course_dict: dict) -> "OnlineCourse": | ||
if course_dict is None: | ||
return None | ||
return cls( | ||
name=course_dict["name"], | ||
description=course_dict["description"], | ||
weeks=OnlineCourse.days_to_weeks(course_dict["days"]), | ||
) |