diff --git a/python/NTT_Test.py b/python/NTT_Test.py index ae9199a..18c2b9b 100644 --- a/python/NTT_Test.py +++ b/python/NTT_Test.py @@ -301,7 +301,7 @@ def test_get_small_multiplication_table(self): def test_get_multiplication_table_20(self): # Given - expected = (" 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |\n" + expected =(" 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |\n" " 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 |\n" " 3 | 6 | 9 | 12 | 15 | 18 | 21 | 24 | 27 | 30 | 33 | 36 | 39 | 42 | 45 | 48 | 51 | 54 | 57 | 60 |\n" " 4 | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 |\n" diff --git a/python/NumberUtilities.py b/python/NumberUtilities.py index 74023b2..55b3fb4 100644 --- a/python/NumberUtilities.py +++ b/python/NumberUtilities.py @@ -15,8 +15,8 @@ def get_exponentiations(start, stop, step, exponent): Returns: String concatenation of exponential values """ - return None - + return "".join(str(i**exponent) for i in range(start, stop, step)) + def get_range(start, stop=None, step=1): """ @@ -32,7 +32,7 @@ def get_range(start, stop=None, step=1): # Single parameter version: get_range(stop) stop = start start = 0 - return None + return "".join(str(i) for i in range(start, stop, step)) def is_number_even(to_test): @@ -43,7 +43,7 @@ def is_number_even(to_test): Returns: Boolean indicating if number is even """ - return False + return True if to_test%2==0 else False def is_number_odd(to_test): @@ -54,7 +54,7 @@ def is_number_odd(to_test): Returns: Boolean indicating if number is odd """ - return False + return True if to_test%2==1 else False def get_even_numbers(start, stop): @@ -66,7 +66,7 @@ def get_even_numbers(start, stop): Returns: String concatenation of even numbers """ - return None + return "".join(str(i) for i in range(start, stop) if is_number_even(i)==True) def get_odd_numbers(start, stop): @@ -78,7 +78,7 @@ def get_odd_numbers(start, stop): Returns: String concatenation of odd numbers """ - return None + return "".join(str(i) for i in range(start, stop) if is_number_odd(i)==True) def get_square_numbers(start, stop, step): @@ -91,4 +91,4 @@ def get_square_numbers(start, stop, step): Returns: String concatenation of squared numbers """ - return None \ No newline at end of file + return get_exponentiations(start, stop, step, 2) \ No newline at end of file diff --git a/python/TableUtilities.py b/python/TableUtilities.py index 0197df1..d513a6e 100644 --- a/python/TableUtilities.py +++ b/python/TableUtilities.py @@ -12,7 +12,16 @@ def get_multiplication_table(table_size): Returns: String representation of formatted multiplication table """ - return None + + """ + out_str="" + for i in range(1, table_size+1): + out_str += " |".join(f'{i * j:>3}' for j in range(1, table_size + 1)) + " |\n" + return out_str + """ + #I did all functions here in one line each so why break it + return "\n".join((" |".join(f'{i * j:>3}' for j in range(1, table_size + 1)) + " |") for i in range(1, table_size+1))+"\n" + def get_small_multiplication_table(): @@ -21,7 +30,7 @@ def get_small_multiplication_table(): Returns: String representation of 4x4 multiplication table """ - return None + return get_multiplication_table(5) def get_large_multiplication_table(): @@ -30,4 +39,4 @@ def get_large_multiplication_table(): Returns: String representation of 10x10 multiplication table """ - return None \ No newline at end of file + return get_multiplication_table(10) \ No newline at end of file diff --git a/python/TriangleUtilities.py b/python/TriangleUtilities.py index f32c390..48ed6c3 100644 --- a/python/TriangleUtilities.py +++ b/python/TriangleUtilities.py @@ -12,7 +12,7 @@ def get_row(number_of_stars): Returns: String of asterisks """ - return None + return "*" * number_of_stars def get_triangle(number_of_rows): @@ -23,7 +23,11 @@ def get_triangle(number_of_rows): Returns: String representation of triangle """ - return None + return "\n".join(get_row(i) for i in range(1,number_of_rows))+"\n" + + + + def get_small_triangle(): @@ -32,7 +36,7 @@ def get_small_triangle(): Returns: String representation of 4-row triangle """ - return None + return get_triangle(5) def get_large_triangle(): @@ -41,4 +45,4 @@ def get_large_triangle(): Returns: String representation of 10-row triangle """ - return None \ No newline at end of file + return get_triangle(10) \ No newline at end of file diff --git a/python/__pycache__/NumberUtilities.cpython-312.pyc b/python/__pycache__/NumberUtilities.cpython-312.pyc new file mode 100644 index 0000000..c0e40f1 Binary files /dev/null and b/python/__pycache__/NumberUtilities.cpython-312.pyc differ diff --git a/python/__pycache__/NumberUtilities.cpython-313.pyc b/python/__pycache__/NumberUtilities.cpython-313.pyc new file mode 100644 index 0000000..592d0d8 Binary files /dev/null and b/python/__pycache__/NumberUtilities.cpython-313.pyc differ diff --git a/python/__pycache__/TableUtilities.cpython-312.pyc b/python/__pycache__/TableUtilities.cpython-312.pyc new file mode 100644 index 0000000..91f7da2 Binary files /dev/null and b/python/__pycache__/TableUtilities.cpython-312.pyc differ diff --git a/python/__pycache__/TableUtilities.cpython-313.pyc b/python/__pycache__/TableUtilities.cpython-313.pyc new file mode 100644 index 0000000..0e400a7 Binary files /dev/null and b/python/__pycache__/TableUtilities.cpython-313.pyc differ diff --git a/python/__pycache__/TriangleUtilities.cpython-312.pyc b/python/__pycache__/TriangleUtilities.cpython-312.pyc new file mode 100644 index 0000000..a16e159 Binary files /dev/null and b/python/__pycache__/TriangleUtilities.cpython-312.pyc differ diff --git a/python/__pycache__/TriangleUtilities.cpython-313.pyc b/python/__pycache__/TriangleUtilities.cpython-313.pyc new file mode 100644 index 0000000..40183c0 Binary files /dev/null and b/python/__pycache__/TriangleUtilities.cpython-313.pyc differ