




from datetime import date

import requests

_UpperCAmelCase						:    Union[str, Any]      =  "https://api.carbonintensity.org.uk/intensity"



def    UpperCAmelCase__	(  ):
  lowercase     :Union[str, Any]   						=    requests.get(lowerCamelCase ).json()["data"][0]
  return last_half_hour["intensity"]["actual"]



def    UpperCAmelCase__	(  lowerCamelCase,      lowerCamelCase ):
  return requests.get(F"{BASE_URL}/{start}/{end}" ).json()["data"]


if __name__ == "__main__":
     for entry in fetch_from_to(start=date(2020, 10, 1), end=date(2020, 10, 3)):
          print("from {from} to {to}: {intensity[actual]}".format(**entry))
     print(f'''{fetch_last_half_hour() = }''')









def    UpperCAmelCase__	(  lowerCamelCase ):
  lowercase     :Optional[int]   						=    len(lowerCamelCase )
  if n in (0, 1):
    return 0
  return sum(query * (n - i - 1) for i, query in enumerate(sorted(lowerCamelCase ) ) )


if __name__ == "__main__":
     import doctest

     doctest.testmod()



