Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/NTT_Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions python/NumberUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -91,4 +91,4 @@ def get_square_numbers(start, stop, step):
Returns:
String concatenation of squared numbers
"""
return None
return get_exponentiations(start, stop, step, 2)
15 changes: 12 additions & 3 deletions python/TableUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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():
Expand All @@ -30,4 +39,4 @@ def get_large_multiplication_table():
Returns:
String representation of 10x10 multiplication table
"""
return None
return get_multiplication_table(10)
12 changes: 8 additions & 4 deletions python/TriangleUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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():
Expand All @@ -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():
Expand All @@ -41,4 +45,4 @@ def get_large_triangle():
Returns:
String representation of 10-row triangle
"""
return None
return get_triangle(10)
Binary file not shown.
Binary file not shown.
Binary file added python/__pycache__/TableUtilities.cpython-312.pyc
Binary file not shown.
Binary file added python/__pycache__/TableUtilities.cpython-313.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.