Code Monkey home page Code Monkey logo

py-online-course's Introduction

Online Course

We want to create a website for finding the best online courses. In order to store information about courses, we need a new OnlineCourse class. Could you implement it for us?

OnlineCourse constructor takes three arguments:

  • name - course name (should be stored in self.name)
  • description - course description (should be stored in self.description)
  • weeks - duration of the course in weeks (should be stored in self.weeks)
course = OnlineCourse(
    name="Python Basics",
    description="The best course to start learning Python",
    weeks=2,
)
print(course.description)  # The best course to start learn Python

Often we will receive information about the course in the form of a course_dict dictionary with such fields:

  • course_dict["name"] - course name
  • course_dict["description"] - course description
  • course_dict["days"] - duration of the course in days

To convert course duration to weeks, OnlineCourse should have days_to_weeks staticmethod, that takes one argument days and convert this number to weeks.

Note: The last week may not be whole.

Example:

OnlineCourse.days_to_weeks(10) == 2
OnlineCourse.days_to_weeks(14) == 2
OnlineCourse.days_to_weeks(15) == 3

OnlineCourse should have from_dict classmethod. It should take two parameters:

  • cls - a default parameter for classmethod
  • course_dict - a dictionary described above

Method should return a new instance of OnlineCourse with correct attributes. It should use days_to_weeks method to convert days to weeks. Example:

course_dict = {
    "name": "Python Core",
    "description": "After this course you will know everything about Python",
    "days": 12,
}
python_course = OnlineCourse.from_dict(course_dict)
print(python_course.weeks)  # 2

py-online-course's People

Contributors

abnormaltype avatar ivanramyk avatar nattalli avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.