From 0da2b5aa11c8f350df705107452d1f9dab9271d1 Mon Sep 17 00:00:00 2001 From: Vignesh Date: Sat, 6 Jun 2020 21:29:19 +0530 Subject: [PATCH 1/4] created perfect_cube.py To find whether a number is a perfect cube or not. --- maths/perfect_cube.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 maths/perfect_cube.py diff --git a/maths/perfect_cube.py b/maths/perfect_cube.py new file mode 100644 index 000000000000..44fa66bb1750 --- /dev/null +++ b/maths/perfect_cube.py @@ -0,0 +1,15 @@ +def perfect_cube(n: int) -> bool: + """ + Check if a number is a perfect cube or not. + >>>perfect_cube(27) + True + >>>perfect_cube(4) + False + """ + val = n ** (1 / 3) + return (val * val * val) == n + + +if(__name__ == '__main__'): + print(perfect_cube(27)) + print(perfect_cube(4)) From 3ef62a5995f4368e2958ba40728279c3b409765f Mon Sep 17 00:00:00 2001 From: Vignesh Date: Sat, 6 Jun 2020 21:35:21 +0530 Subject: [PATCH 2/4] Update perfect_cube.py --- maths/perfect_cube.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/maths/perfect_cube.py b/maths/perfect_cube.py index 44fa66bb1750..a2ec54b6b64a 100644 --- a/maths/perfect_cube.py +++ b/maths/perfect_cube.py @@ -1,15 +1,15 @@ def perfect_cube(n: int) -> bool: - """ - Check if a number is a perfect cube or not. - >>>perfect_cube(27) - True - >>>perfect_cube(4) - False - """ - val = n ** (1 / 3) - return (val * val * val) == n + """ + Check if a number is a perfect cube or not. + >>>perfect_cube(27) + True + >>>perfect_cube(4) + False + """ + val = n ** (1 / 3) + return (val * val * val) == n if(__name__ == '__main__'): - print(perfect_cube(27)) - print(perfect_cube(4)) + print(perfect_cube(27)) + print(perfect_cube(4)) From 8581fa58e407fa0f5d843833723bfe7fadc4840f Mon Sep 17 00:00:00 2001 From: Vignesh Date: Sat, 6 Jun 2020 21:49:12 +0530 Subject: [PATCH 3/4] Update perfect_cube.py --- maths/perfect_cube.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/maths/perfect_cube.py b/maths/perfect_cube.py index a2ec54b6b64a..66435090d95e 100644 --- a/maths/perfect_cube.py +++ b/maths/perfect_cube.py @@ -1,9 +1,10 @@ def perfect_cube(n: int) -> bool: """ Check if a number is a perfect cube or not. - >>>perfect_cube(27) + + >>> perfect_cube(27) True - >>>perfect_cube(4) + >>> perfect_cube(4) False """ val = n ** (1 / 3) From 8cd76f26efb9a9ad127450f56f24e52fa0cf2940 Mon Sep 17 00:00:00 2001 From: Vignesh Date: Sat, 6 Jun 2020 21:50:41 +0530 Subject: [PATCH 4/4] Update perfect_cube.py --- maths/perfect_cube.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/perfect_cube.py b/maths/perfect_cube.py index 66435090d95e..f65795ba8686 100644 --- a/maths/perfect_cube.py +++ b/maths/perfect_cube.py @@ -1,7 +1,7 @@ def perfect_cube(n: int) -> bool: """ Check if a number is a perfect cube or not. - + >>> perfect_cube(27) True >>> perfect_cube(4)