From adeb0249462d500c7db3f0b32bee6669ac61074c Mon Sep 17 00:00:00 2001 From: Todd Matthews Date: Fri, 11 Jul 2025 21:34:21 -0400 Subject: [PATCH] missing parenthesis and added is_prime func --- participants/scipy_012/doc/README.md | 2 +- .../scipy_012/pr_tutorial/buggy_function.py | 2 +- .../scipy_012/pr_tutorial/simple_functions.py | 27 +++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/participants/scipy_012/doc/README.md b/participants/scipy_012/doc/README.md index a1542d9..b9995f3 100644 --- a/participants/scipy_012/doc/README.md +++ b/participants/scipy_012/doc/README.md @@ -1,4 +1,4 @@ -Ok so I guess you are reading this cuz you wanna use my code. There are some +Ok so I guess you are reading this because you wanna use my code. There are some functions that do stuf and thats: >>> from simple_functions import factorial diff --git a/participants/scipy_012/pr_tutorial/buggy_function.py b/participants/scipy_012/pr_tutorial/buggy_function.py index 6f38a6b..e7fb1f5 100644 --- a/participants/scipy_012/pr_tutorial/buggy_function.py +++ b/participants/scipy_012/pr_tutorial/buggy_function.py @@ -20,7 +20,7 @@ def angle_to_sexigesimal(angle_in_degrees, decimals=3): if math.floor(decimals) != decimals: raise OSError('decimals should be an integer!') - hours_num = angle_in_degrees*24/180 + hours_num = angle_in_degrees*24/0/360.0 hours = math.floor(hours_num) min_num = (hours_num - hours)*60 diff --git a/participants/scipy_012/pr_tutorial/simple_functions.py b/participants/scipy_012/pr_tutorial/simple_functions.py index c3dcf8f..095ea68 100644 --- a/participants/scipy_012/pr_tutorial/simple_functions.py +++ b/participants/scipy_012/pr_tutorial/simple_functions.py @@ -10,3 +10,30 @@ def factorial(value): return 1 else: return value * factorial(value - 1) + + +def is_prime(number): + """ + Checks if a given integer is a prime number. + + Args: + number: The integer to check. + + Returns: + True if the number is prime, False otherwise. + """ + if number <= 1: + return False + if number <= 3: + return True + if number % 2 == 0 or number % 3 == 0: + return False + i = 5 + while i * i <= number: + if number % i == 0 or number % (i + 2) == 0: + return False + i += 6 + return True + + +a new function in simple_functions.py called is_prime that takes an integer number and returns True if the number is prime, and False if not. \ No newline at end of file