Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Licence CC BY-NC-ND Thierry Parmentelat & Arnaud Legout Inria - UCA

Exercice - niveau basique

Répartiteur (1)

On vous demande d’écrire une fonction dispatch1, qui prend en argument deux entiers a et b, et qui renvoie selon les cas :

 a paira impairb paira2+b2(a1)bb impaira(b1)a2b2\begin{array}{c|c|c} \ & a\ pair & a\ impair \\ \hline b\ pair & a^2+b^2 & (a-1)*b\\ \hline b\ impair & a*(b-1)& a^2-b^2\\ \end{array}
# un petit exemple
from corrections.exo_dispatch import exo_dispatch1
exo_dispatch1.example()
Loading...
def dispatch1(a, b):
    "<votre_code>"
# pour vérifier votre code
exo_dispatch1.correction(dispatch1)
Loading...

Exercice - niveau basique

Répartiteur (2)

Dans une seconde version de cet exercice, on vous demande d’écrire une fonction dispatch2 qui prend en arguments :

et qui renvoie selon les cas :

 aAaAbBa2+b2(a1)bbBa(b1)a2+b2\begin{array}{c|c|c} \ & a \in A & a\notin A \\ \hline b\in B & a^2+b^2 & (a-1)*b\\ \hline b\notin B & a*(b-1)& a^2+b^2\\ \end{array}
# un exemple
from corrections.exo_dispatch import exo_dispatch2
exo_dispatch2.example()
Loading...
# à vous
def dispatch2(a, b, A, B):
    "<votre_code>"
# pour vérifier votre code
exo_dispatch2.correction(dispatch2)
Loading...