From 4b8c0ca1c597d478742f32623c1316b59681b19f Mon Sep 17 00:00:00 2001 From: Pratyusha <133910229+pratyusha-samidhapudi@users.noreply.github.com> Date: Thu, 23 Nov 2023 21:08:59 -0500 Subject: [PATCH 1/6] Fixed the issue #69 --- src/FindSquare/square.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/FindSquare/square.py diff --git a/src/FindSquare/square.py b/src/FindSquare/square.py new file mode 100644 index 0000000..69dc8e9 --- /dev/null +++ b/src/FindSquare/square.py @@ -0,0 +1,23 @@ +def calculate_square(number): + return number ** 2 + +def main(): + # Ask the user for a number + user_input = input("Enter a number: ") + + try: + # To cast the input to a numeric type + number = float(user_input) + + # Calculate the square value + square_value = calculate_square(number) + + # Print out the result + print(f"The square value of {number} is: {square_value}") + + except ValueError: + # Handle the case where the input cannot be cast to a numeric type + print("Invalid input. Please enter a valid number.") + +if __name__ == "__main__": + main() From 83e7e85f768fc184c0390393f2ce2c8ae2aac0bf Mon Sep 17 00:00:00 2001 From: Pratyusha <133910229+pratyusha-samidhapudi@users.noreply.github.com> Date: Thu, 23 Nov 2023 21:09:38 -0500 Subject: [PATCH 2/6] Fixed the issue #69 --- tests/FindSquare/test_square.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/FindSquare/test_square.py diff --git a/tests/FindSquare/test_square.py b/tests/FindSquare/test_square.py new file mode 100644 index 0000000..4859403 --- /dev/null +++ b/tests/FindSquare/test_square.py @@ -0,0 +1,14 @@ +from square import calculate_square +def test_square_calculation(): + from square import calculate_square + + # Test with a positive number + assert calculate_square(4) == 16 + + # Test with a negative number + assert calculate_square(-3) == 9 + + # Test with a decimal number + assert calculate_square(2.5) == 6.25 + + From 0fd6020055b3c3dc0cdef09e8f303763f89bea51 Mon Sep 17 00:00:00 2001 From: Pratyusha <133910229+pratyusha-samidhapudi@users.noreply.github.com> Date: Sat, 25 Nov 2023 01:08:22 -0500 Subject: [PATCH 3/6] Update test_square.py --- tests/FindSquare/test_square.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/FindSquare/test_square.py b/tests/FindSquare/test_square.py index 4859403..8a25651 100644 --- a/tests/FindSquare/test_square.py +++ b/tests/FindSquare/test_square.py @@ -1,6 +1,5 @@ -from square import calculate_square +from FileSquare/square import calculate_square def test_square_calculation(): - from square import calculate_square # Test with a positive number assert calculate_square(4) == 16 From 18a09d8bea3aa392d8c1662cd44161967d3069f5 Mon Sep 17 00:00:00 2001 From: Pratyusha <133910229+pratyusha-samidhapudi@users.noreply.github.com> Date: Sat, 25 Nov 2023 01:12:00 -0500 Subject: [PATCH 4/6] Update square.py --- src/FindSquare/square.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/FindSquare/square.py b/src/FindSquare/square.py index 69dc8e9..3a0dc31 100644 --- a/src/FindSquare/square.py +++ b/src/FindSquare/square.py @@ -1,7 +1,23 @@ def calculate_square(number): + """ + Calculate the square value of a given number. + + Parameters: + - number (float): The input number for which the square value is calculated. + + Returns: + - float: The square value of the input number. + """ return number ** 2 def main(): + """ + The main function of the program. It takes user input, calculates the square value, + and prints the result. + + Usage: + - Run this script to input a number and get its square value. + """ # Ask the user for a number user_input = input("Enter a number: ") From d6d96bc9339f938df224eb3cd0e7fe7572daa122 Mon Sep 17 00:00:00 2001 From: Pratyusha <133910229+pratyusha-samidhapudi@users.noreply.github.com> Date: Sat, 25 Nov 2023 01:14:02 -0500 Subject: [PATCH 5/6] Update test_square.py --- tests/FindSquare/test_square.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FindSquare/test_square.py b/tests/FindSquare/test_square.py index 8a25651..7a06445 100644 --- a/tests/FindSquare/test_square.py +++ b/tests/FindSquare/test_square.py @@ -1,4 +1,4 @@ -from FileSquare/square import calculate_square +from FindSquare/square import calculate_square def test_square_calculation(): # Test with a positive number From 4752898551111213babdc4166b473b9d3a8ad197 Mon Sep 17 00:00:00 2001 From: Pratyusha <133910229+pratyusha-samidhapudi@users.noreply.github.com> Date: Sat, 25 Nov 2023 01:14:48 -0500 Subject: [PATCH 6/6] Update test_square.py --- tests/FindSquare/test_square.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FindSquare/test_square.py b/tests/FindSquare/test_square.py index 7a06445..2956f25 100644 --- a/tests/FindSquare/test_square.py +++ b/tests/FindSquare/test_square.py @@ -1,4 +1,4 @@ -from FindSquare/square import calculate_square +from FindSquare.square import calculate_square def test_square_calculation(): # Test with a positive number