<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_quarter(cls, year, quarter):
 """ Create ``daterange`` based on a year and quarter. A quarter is considered to be: - January through March (Q1), - April through June (Q2), - July through September (Q3) or, - October through December (Q4) :param year: Year as an integer :param quarter: Quarter as an integer between 1 and 4 :return: A new ``daterange`` for the given quarter .. versionadded:: 0.4.0 """


        quarter_months = {
            1: 1,
            2: 4,
            3: 7,
            4: 10,
        }

        if quarter not in quarter_months:
            error_msg = (
                "quarter is not a valid quarter. Expected a value between 1 "
                "and 4 got {!r}")
            raise ValueError(error_msg.format(quarter))

        first_day = date(year, quarter_months[quarter], 1)
        return cls.from_date(first_day, period="quarter")