<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_announcements(self, site=None, num=10, age=20):
 """ Gets announcements from a site if site is not None, or from every site otherwise. Returns a list of TSquareAnnouncement objects. @param site_obj (TSquareSite) If non-None, gets only the announcements from that site. If none, get anouncements from all sites. @param num - The number of announcements to fetch. Default is 10. @param age - 'How far back' to go to retreive announcements. Default is 20, which means that only announcements that are less than 20 days old will be returned, even if there less than 'num' of them. @returns - A list of TSquareAnnouncement objects. The length will be at most num, and it may be less than num depending on the number of announcements whose age is less than age. """

        url = BASE_URL_TSQUARE + 'announcement/'
        if site:
            url += 'site/{}.json?n={}&d={}'.format(site.id, num, age)
        else:
            url += 'user.json?n={}&d={}'.format(num, age)
        request = self._session.get(url)
        request.raise_for_status()
        announcement_list = request.json()['announcement_collection']
        return map(lambda x: TSquareAnnouncement(**x), announcement_list)