Check 4.4
Which of the following operations should you use if you want to put [3, 4]
onto the back of [1, 2]
(held in the variable lst) to create [1, 2, 3, 4]
? There may be multiple correct answers. Modify the function below to return a string of answers separated by commas.
- lst.append([3, 4])
- lst.append(3, 4)
- lst += [3, 4]
- lst.extend([3, 4])
- lst.extend(3, 4)
- lst.insert(-1, [3,4])
def answer():
# Insert your answer letters below
return "H,I,J,K"
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 = []
try:
capture = captureIO()
sys.stdout = capture
sys.stderr = capture
exec(student_code)
output = answer().lower()
output = output.replace(" ", "")
output = output.replace(",", "")
output = ''.join(sorted(output))
certificate.append((output, type(output)))
except:
pass
set_certificate(certificate_div_id, str(certificate))