logo

Crowdly

Browser

Add to Chrome

25-In211-Pratique de la programmation en Python 1-

Looking for 25-In211-Pratique de la programmation en Python 1- test answers and solutions? Browse our comprehensive collection of verified answers for 25-In211-Pratique de la programmation en Python 1- at moodle.ipsa.fr.

Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!

View this question
View this question

Qu'affiche le code python suivant?

def access(user):

    match user:

        case "admin" | "manager":

            return "Full access."

        case "Guest":

            return "Limited access."

        case _:

            return "No access."

print(access('User'))

print(access('manager'))

0%
0%
0%
0%
View this question

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%
View this question

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",),))

0%
0%
0%
100%
0%
View this question

Le constructeur d'une classe correspond à : 

0%
0%
0%
100%
View this question

Analysez le code suivant et identifiez le(s) problème(s) potentiel(s) :

import json

file = open("data.json", "r")

data =

json.load(file)

print(data["key"])

print(f"Clé

introuvable : {e}")

print("Fichier non trouvé")

file.close()

0%
0%
0%
0%
View this question

Quelle affichage produit le code python suivant?

D = {'pomme': 3, 'orange': 6, 'tomate': 2}

try:

   x = D['banane']

   print(x)

except TypeError:

   print("Error1")

except KeyError:

   print("Error2")
0%
33%
67%
0%
View this question

Qu'affiche le code python suivant?

def http_response(status):

   match status:

       case 200 | 201:

           return "Success"

       case 500 | 502 | 503:

           return "Server Error"

       case _:

           return "Unknown Status"

print(http_response(500)) 

print(http_response(202)) 

0%
0%
0%
100%
View this question

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