✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Qu'affiche le code Python suivant ?
def cc(*cmds):
stack = []
outputs = []
for c in cmds:
match c:
case ("push", x):
stack.append(x)
case ("pop",):
if stack:
outputs.append(stack.pop())
case ("sum",):
if len(stack) >= 2:
a = stack.pop()
b = stack.pop()
stack.append(a + b)
case _:
pass
return outputs
print(cc(("push", 1), ("pop",), ("pop",)),
cc(("push", 1), ("push", -1), ("sum",), ("pop",)),
cc(("pop",),))