title: Simulation using a Queue
body: <p>I am trying to simulate the following simple scenario using a queue:</p>
  
  <p>"Students come to a professor's office to receive help on a homework assignment every 10 minutes exponentially distributed. The time to help a student is exponentially distributed with a mean of 7 minutes. What are the expected number of students waiting to be helped and the average waiting time before being helped? For what percentage of time is it expected there will be more than two students at the professor's office?"</p>
  
  <p>I started by making the following queue but I'm struggling how to create a global time clock and how to integrate students leaving the queue.</p>
  
  <pre><code>import random as rd
  
  class Queue(object):
      def __init__(self):
          self.officeHasStudent = False
          self.totalTime = 0
          self.numStudentsInLine = 0
      def studentArrives(self, time):
          self.totalTime += time
          if self.officeHasStudent == False:
              self.officeHasStudent = True
          else:
              self.numStudentsInLine += 1
      def __str__(self):
          temp = ''
          temp += 'Time Elapsed: ' + str(self.totalTime) + ' min\n'
          temp += 'number of students in line: ' + str(self.numStudentsInLine)
          return temp
  
  Q = Queue()
  
  for i in range(5):
      Q.studentArrives(rd.expovariate(1/10.0))
  
  print(Q)
  </code></pre>