From 46e9a61a30988df85f611dbe143745764724998d Mon Sep 17 00:00:00 2001 From: THERY Eli Date: Sun, 16 Mar 2025 18:55:49 +0100 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'points.py'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- points.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/points.py b/points.py index 54aa5f5..ebf48a0 100644 --- a/points.py +++ b/points.py @@ -1,15 +1,14 @@ -import math - def points(x, y): """Détermine si un tir vaut 2 ou 3 points en fonction de sa position.""" - # Centre du demi-cercle : (0, 300) | Rayon : 150 pixels - if x <= 150 and math.sqrt(x**2 + (y - 300)**2) <= 150: + if x <= 150 and (y - 300) ** 2 + x ** 2 <= 150 ** 2: return 2 - if x >= 850 and math.sqrt((x - 1000)**2 + (y - 300)**2) <= 150: + + if x >= 850 and (y - 300) ** 2 + (x - 1000) ** 2 <= 150 ** 2: return 2 + return 3 # Test de la fonction if __name__ == "__main__": - print(points(50, 300)) # Doit retourner 2 - print(points(500, 300)) # Doit retourner 3 + print(points(50, 300)) # Devrait retourner 2 (tir à l'intérieur du demi-cercle) + print(points(500, 300)) # Devrait retourner 3 (tir en dehors des demi-cercles)