✅ 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 ee(*ops, **kwargs):
strict = kwargs.get("strict", False)
results = []
for op in ops:
match op:
case ("add", x, y):
results.append(x + y)
case ("sub", x, y):
results.append(x - y)
case ("mul", x, y):
results.append(x * y)
case ("div", x, y):
try:
results.append(x / y)
except ZeroDivisionError:
if strict:
raise ZeroDivisionError
results.append(None)
case _:
pass
return results
print(ee(("add", 2, 3), ("mul", 3, 4)),
ee(("div", 1, 0), ("div", 4, 2)),
ee(("noop",), ("sub", 5, 2), ("div", 10, 5)))