Factorisation de tests

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
Yohann D'ANELLO 2021-01-26 16:45:23 +01:00
parent ecec88e230
commit d8c6b6e6bf
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 7 additions and 25 deletions

32
main.py
View File

@ -59,37 +59,19 @@ def calcul(left: int, right: int, res: int, operation='+'):
Vérifie si left operation b == c, a, b et c sont des entiers. Vérifie si left operation b == c, 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