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.
L'opération peut être +, -, *, /, &, |, ^, % ou l'un de ses alias anglais.
"""
if operation == '+':
if operation in ['+', 'add', 'sum']:
result = left + right
if operation == 'sum':
result = left + right
if operation == 'add':
result = left + right
if operation == '-':
if operation in ['-', 'sub']:
result = left - right
if operation == 'sub':
result = left - right
if operation == '*':
if operation in ['*', 'mul', 'prod']:
result = left * right
if operation == 'mul':
result = left * right
if operation == 'prod':
result = left * right
if operation == '/':
if operation in ['/', 'div']:
result = left / right
if operation == 'div':
result = left / right
if operation == '&':
if operation in ['&', 'and']:
result = left & right
if operation == 'and':
result = left & right
if operation == '|':
if operation in ['|', 'or']:
result = left | right
if operation == 'or':
result = left | right
if operation == '^':
result = left ^ right
if operation == 'xor':
if operation in ['^', 'xor']:
result = left ^ right
else:
result = left % right