Check 8.3
Imagine that the student class has a self.mood property. Each student's self.mood is a string like 'happy', 'tired', 'excited', 'hungry', or 'cozy'. Some student methods might change self.mood. Strings are an immutable data type though, so we could create a hash value from self.mood ... but is it a bad idea to write a hash function that includes self.mood? Why or why not?
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
def make_certificate(student_code_div_id, certificate_div_id):
student_code = get_student_code(student_code_div_id)
certificate = []
length_cap, filler_char = 70, 'x'
try:
output = ""
for c in student_code:
output += filler_char
output = output[:length_cap]
certificate.append((output, type(output)))
except:
set_certificate(certificate_div_id, "error")
set_certificate(certificate_div_id, str(certificate))