




"""simple docstring"""




from __future__ import annotations







def       __UpperCAmelCase      (				__UpperCamelCase					):
   __lowercase	:       List[Any]				=   [0] * len(__UpperCamelCase					)
   for i in range(1					,							len(__UpperCamelCase					)					):
      __lowercase	:       Optional[Any]				=   duration_times[i - 1] + waiting_times[i - 1]
   return waiting_times







def       __UpperCAmelCase      (				__UpperCamelCase					,							__UpperCamelCase					):
   return [
       duration_time + waiting_times[i]
       for i, duration_time in enumerate(__UpperCamelCase					)
   ]







def       __UpperCAmelCase      (				__UpperCamelCase					):
   return sum(__UpperCamelCase					) / len(__UpperCamelCase					)







def       __UpperCAmelCase      (				__UpperCamelCase					):
   return sum(__UpperCamelCase					) / len(__UpperCamelCase					)


if __name__ == "__main__":
   # process id's
   a_            =   [1, 2, 3]

   # ensure that we actually have processes
   if len(processes) == 0:
      print('Zero amount of processes')
      raise SystemExit(0)

   # duration time of all processes
   a_            =   [1_9, 8, 9]

   # ensure we can match each id to a duration time
   if len(duration_times) != len(processes):
      print('Unable to match all id\'s with their duration time')
      raise SystemExit(0)

   # get the waiting times and the turnaround times
   a_            =   calculate_waiting_times(duration_times)
   a_            =   calculate_turnaround_times(duration_times, waiting_times)

   # get the average times
   a_            =   calculate_average_waiting_time(waiting_times)
   a_            =   calculate_average_turnaround_time(turnaround_times)

   # print all the results
   print('Process ID\tDuration Time\tWaiting Time\tTurnaround Time')
   for i, process in enumerate(processes):
      print(
          F"{process}\t\t{duration_times[i]}\t\t{waiting_times[i]}\t\t"
          F"{turnaround_times[i]}"
      )
   print(F"Average waiting time = {average_waiting_time}")
   print(F"Average turn around time = {average_turnaround_time}")









"""simple docstring"""




a_            =   1_0_0_0







def       __UpperCAmelCase      (				__UpperCamelCase					):
			return x * x







def       __UpperCAmelCase      (				__UpperCamelCase					,							__UpperCamelCase					,							__UpperCamelCase					,							__UpperCamelCase = 4					):
			assert callable(
			    __UpperCamelCase					), f"""the function(object) passed should be callable your input : {function}"""
			assert isinstance(__UpperCamelCase					,							(float, int)					), f"""a should be float or integer your input : {a}"""
			assert isinstance(function(__UpperCamelCase					)					,							(float, int)					), (
			    "the function should return integer or float return type of your function, "
			    f"""{type(__UpperCamelCase					)}"""
			)
			assert isinstance(__UpperCamelCase					,							(float, int)					), f"""b should be float or integer your input : {b}"""
			assert (
			    isinstance(__UpperCamelCase					,							__UpperCamelCase					) and precision > 0
			), f"""precision should be positive integer your input : {precision}"""

			# just applying the formula of simpson for approximate integration written in
			# mentioned article in first comment of this file and above this function

			__lowercase	:       Optional[Any]				=   (b - a) / N_STEPS
			__lowercase	:       Optional[int]				=   function(__UpperCamelCase					) + function(__UpperCamelCase					)

			for i in range(1					,							__UpperCamelCase					):
						__lowercase	:       Union[str, Any]				=   a + h * i
						result += function(__UpperCamelCase					) * (4 if i % 2 else 2)

			result *= h / 3
			return round(__UpperCamelCase					,							__UpperCamelCase					)


if __name__ == "__main__":
			import doctest

			doctest.testmod()



