def semester(date, *, base=1):
    """
    Returns the semester of the given date.

    The first semester runs from 1 January to 30 June; the second
    from 1 July to 31 December.

    Parameters
    ----------
    date : datetime.date
        the date from which to determine the semester
    base : int, optional
        the index of the first semester (default is 1)

    Returns
    -------
    int
        semester's index

    Examples
    ------------
    >>> semester(datetime.date(2020, 1, 10))
    1

    >>> semester(datetime.date(2020, 1, 10), base=0)
    0

    See also
    --------
    trimester, quarter
    """
    return (date.month - 1) // 6 + base