From d8c6b6e6bfb22e133b8c57ea5538b1cb32c7e2fc Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 26 Jan 2021 16:45:23 +0100 Subject: [PATCH] Factorisation de tests Signed-off-by: Yohann D'ANELLO --- main.py | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/main.py b/main.py index 8416900..a59075f 100644 --- a/main.py +++ b/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. 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