




'''simple docstring'''



from __future__ import annotations

from statistics import mean







def 			_UpperCamelCase (_lowerCamelCase							:     list[int]	)->   list[int]:




     '''simple docstring'''





     __snake_case    					=  2
     __snake_case    					=  list(_lowerCamelCase	)
     __snake_case    					=  [0] * len(_lowerCamelCase	)
     __snake_case    					=  0
     while True:
          __snake_case    					=  True
          for i, burst_time in enumerate(_lowerCamelCase	):
               if rem_burst_times[i] > 0:
                    __snake_case    					=  False
                    if rem_burst_times[i] > quantum:
                         t += quantum
                         rem_burst_times[i] -= quantum
                    else:
                         t += rem_burst_times[i]
                         __snake_case    					=  t - burst_time
                         __snake_case    					=  0
          if done is True:
               return waiting_times







def 			_UpperCamelCase (_lowerCamelCase							:     list[int]   ,	_lowerCamelCase							:     list[int]	)->   list[int]:




     '''simple docstring'''





     return [burst + waiting for burst, waiting in zip(_lowerCamelCase   ,	_lowerCamelCase	)]


if __name__ == "__main__":
     UpperCAmelCase_       :  List[str]      =		[3, 5, 7]
     UpperCAmelCase_       :  List[str]      =		calculate_waiting_times(burst_times)
     UpperCAmelCase_       :  str      =		calculate_turn_around_times(burst_times, waiting_times)
     print('''Process ID \tBurst Time \tWaiting Time \tTurnaround Time''')
     for i, burst_time in enumerate(burst_times):
          print(
              F"""  {i + 1}\t\t  {burst_time}\t\t  {waiting_times[i]}\t\t  """
              F"""{turn_around_times[i]}"""
          )
     print(F"""\nAverage waiting time = {mean(waiting_times):.5f}""")
     print(F"""Average turn around time = {mean(turn_around_times):.5f}""")












'''simple docstring'''



from datetime import date

import requests

UpperCAmelCase_       :  str      =		'''https://api.carbonintensity.org.uk/intensity'''







def 			_UpperCamelCase ()->   str:




     '''simple docstring'''





     __snake_case    					=  requests.get(_lowerCamelCase	).json()['''data'''][0]
     return last_half_hour["intensity"]["actual"]







def 			_UpperCamelCase (_lowerCamelCase							:     Dict   ,	_lowerCamelCase							:     List[Any]	)->   list:




     '''simple docstring'''





     return requests.get(f'''{BASE_URL}/{start}/{end}'''	).json()["data"]


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






