CMU 15-112 Spring 2019: Fundamentals of Programming and Computer Science
Check 5.5


  1. Check 5.5
    In the init(data) function of the animation starter code, what value should you set data.timerDelay to if you want timerFired(data) to run once every two seconds?
    def init(data): # Insert your answer below by setting the correct # value for data.timerDelay data.timerDelay=100 import sys def set_certificate(certificate_div_id, certificate): document[certificate_div_id].textContent = certificate def get_student_code(student_code_div_id): raw_student_code = document[student_code_div_id].textContent return window.patchCodeToCheckTimeout(raw_student_code, 'check_timeout();'); class captureIO: def __init__(self): self.captured = [] def get_output(self): out = "" for c in self.captured: out += str(c) return out def write(self, data): self.captured.append(data) def flush(self): pass class data(object): pass def make_certificate(student_code_div_id, certificate_div_id): try: student_code = get_student_code(student_code_div_id) certificate = [] capture = captureIO() sys.stdout = capture sys.stderr = capture d = data() exec(student_code) init(d) certificate.append((d.timerDelay, type(d.timerDelay))) set_certificate(certificate_div_id, str(certificate)) except: set_certificate(certificate_div_id, "error")

  2. Back to notes