You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But, we could include hidden code to wrap input and print functions, so later we can evaluate them.
Proof-of-Concept:
# wrap functions to store inputs and outputs
inputs = []
outputs = []
i = input
def input(msg):
v = i(msg)
inputs.append(v)
return v
p = print
def print(v):
p(v)
outputs.append(v)
# student code:
n = input("n")
print(int(n) + 2)
# automatic check / grading:
assert not inputs, "your program must read input data"
assert not outputs, "your program must print output results"
assert outputs[0] == int(inputs[0]) + 1, "you must sum 1"
Initial programs don't use
def
so they cannot be invoked in unit test to check results programmatically, for example:https://pyar.github.io/PyZombis/main/lectures/TWP15/TWP15_3.html#algunos-ejercicios
But, we could include hidden code to wrap
input
andprint
functions, so later we can evaluate them.Proof-of-Concept:
Documentation:
https://runestone.academy/ns/books/published/authorguide/directives/activecode.html#incorporating-unit-tests
The text was updated successfully, but these errors were encountered: