import task as previously defined import random def simulation(num_secondspages_per_minute)lab_printer printer(pages_per_minuteprint_queue queue(waiting_times [for current_second in range(num_seconds)if new_print_task()task task(current_secondprint_queue enqueue(taskif (not lab_printer busy()and (not print_queue is_empty())next_task print_queue dequeue(waiting_times append(next_task wait_time(current_second)lab_printer start_next(next_tasklab_printer tick(average_wait sum(waiting_timeslen(waiting_timesprint("average wait % secs % tasks remaining %(average_waitprint_queue size())def new_print_task()num random randrange( if num = return true elsereturn false for in range( )simulation( when we run the simulationwe should not be concerned that the results are different each time this is due to the probabilistic nature of the random numbers we are interested in the trends that may be occurring as the parameters to the simulation are adjusted here are some results firstwe will run the simulation for period of minutes ( secondsusing page rate of five pages per minute in additionwe will run independent trials remember that because the simulation works with random numbers each run will return different results for in range( )simulation( average wait secs tasks remaining average wait secs tasks remaining basic data structures