Factorisation de tests
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
parent
ecec88e230
commit
d8c6b6e6bf
32
main.py
32
main.py
|
@ -59,37 +59,19 @@ def calcul(left: int, right: int, res: int, operation='+'):
|
||||||
Vérifie si left operation b == c, où a, b et c sont des entiers.
|
Vérifie si left operation b == c, où a, b et c sont des entiers.
|
||||||
L'opération peut être +, -, *, /, &, |, ^, % ou l'un de ses alias anglais.
|
L'opération peut être +, -, *, /, &, |, ^, % ou l'un de ses alias anglais.
|
||||||
"""
|
"""
|
||||||
if operation == '+':
|
if operation in ['+', 'add', 'sum']:
|
||||||
result = left + right
|
result = left + right
|
||||||
if operation == 'sum':
|
if operation in ['-', 'sub']:
|
||||||
result = left + right
|
|
||||||
if operation == 'add':
|
|
||||||
result = left + right
|
|
||||||
if operation == '-':
|
|
||||||
result = left - right
|
result = left - right
|
||||||
if operation == 'sub':
|
if operation in ['*', 'mul', 'prod']:
|
||||||
result = left - right
|
|
||||||
if operation == '*':
|
|
||||||
result = left * right
|
result = left * right
|
||||||
if operation == 'mul':
|
if operation in ['/', 'div']:
|
||||||
result = left * right
|
|
||||||
if operation == 'prod':
|
|
||||||
result = left * right
|
|
||||||
if operation == '/':
|
|
||||||
result = left / right
|
result = left / right
|
||||||
if operation == 'div':
|
if operation in ['&', 'and']:
|
||||||
result = left / right
|
|
||||||
if operation == '&':
|
|
||||||
result = left & right
|
result = left & right
|
||||||
if operation == 'and':
|
if operation in ['|', 'or']:
|
||||||
result = left & right
|
|
||||||
if operation == '|':
|
|
||||||
result = left | right
|
result = left | right
|
||||||
if operation == 'or':
|
if operation in ['^', 'xor']:
|
||||||
result = left | right
|
|
||||||
if operation == '^':
|
|
||||||
result = left ^ right
|
|
||||||
if operation == 'xor':
|
|
||||||
result = left ^ right
|
result = left ^ right
|
||||||
else:
|
else:
|
||||||
result = left % right
|
result = left % right
|
||||||
|
|
Loading…
Reference in New Issue