logo

Crowdly

Browser

Add to Chrome

Qu'affiche le code Python suivant ? def ee(*ops, **kwargs): strict = kwa...

✅ 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)))

0%
0%
0%
0%
0%
More questions like this

Want instant access to all verified answers on moodle.ipsa.fr?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome