From f2a97b3b3a0487e0ca6c82c3d7a0426cbd0cbf4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=A9o=20Petitet?= Date: Mon, 16 Dec 2024 13:53:06 +0100 Subject: [PATCH 1/3] modification readme + creation branche --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 823291d..095ad99 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,4 @@ ## Getting Help -If you need help ask on the Slack of the DataCamp course. +If you need help ask on the Slack of the DataCamp course ! From fb324873669a5d2d451ca39c408da9c190f07bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=A9o=20Petitet?= Date: Mon, 16 Dec 2024 15:27:58 +0100 Subject: [PATCH 2/3] UP my solution --- numpy_questions.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/numpy_questions.py b/numpy_questions.py index 07a10c1..98b9cc1 100644 --- a/numpy_questions.py +++ b/numpy_questions.py @@ -41,7 +41,14 @@ def max_index(X): j = 0 # TODO - + if type(X) is not np.ndarray or len(np.shape(X)) != 2: + raise ValueError + val = X[0][0] + for line in range(np.shape(X)[0]): + for col in range(np.shape(X)[1]): + if X[line][col] >= val: + i, j = line, col + val = X[line][col] return i, j @@ -64,4 +71,9 @@ def wallis_product(n_terms): """ # XXX : The n_terms is an int that corresponds to the number of # terms in the product. For example 10000. - return 0. + if n_terms == 0: + return 2.0 + pi_2 = 1 + for n in range(1, n_terms+1): + pi_2 *= (4*n**2)/(4*n**2-1) + return 2*pi_2 From 76fbb610ab52346c3d8dcab48b2c09dd286ec542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=A9o=20Petitet?= Date: Thu, 19 Dec 2024 18:56:52 +0100 Subject: [PATCH 3/3] UP my solution --- numpy_questions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy_questions.py b/numpy_questions.py index 98b9cc1..38511dd 100644 --- a/numpy_questions.py +++ b/numpy_questions.py @@ -72,7 +72,7 @@ def wallis_product(n_terms): # XXX : The n_terms is an int that corresponds to the number of # terms in the product. For example 10000. if n_terms == 0: - return 2.0 + return 2. pi_2 = 1 for n in range(1, n_terms+1): pi_2 *= (4*n**2)/(4*n**2-1)