diff --git a/Project Pattern/pattern_08.py b/Project Pattern/pattern_08.py index 68bb5c7..f2c69dd 100644 --- a/Project Pattern/pattern_08.py +++ b/Project Pattern/pattern_08.py @@ -1,27 +1,27 @@ def pattern_eight(strings): '''Pattern eight - P - P r - P r o - P r o g - P r o g r - P r o g r a - P r o g r a m - P r o g r a m m - P r o g r a m m i - P r o g r a m m i n - P r o g r a m m i n g - P r o g r a m m i n - P r o g r a m m i - P r o g r a m m - P r o g r a m - P r o g r a - P r o g r - P r o g - P r o - P r - P + P + P r + P r o + P r o g + P r o g r + P r o g r a + P r o g r a m + P r o g r a m m + P r o g r a m m i + P r o g r a m m i n + P r o g r a m m i n g + P r o g r a m m i n + P r o g r a m m i + P r o g r a m m + P r o g r a m + P r o g r a + P r o g r + P r o g + P r o + P r + P ''' if not str(strings).isalpha(): diff --git a/Project Pattern/pattern_09.py b/Project Pattern/pattern_09.py index 62b0466..d672444 100644 --- a/Project Pattern/pattern_09.py +++ b/Project Pattern/pattern_09.py @@ -1,15 +1,15 @@ def pattern_nine(strings): '''Pattern nine - K - A - T - H - M - A - N - D - U + K + A + T + H + M + A + N + D + U ''' def method_one(strings): diff --git a/Project Pattern/pattern_10.py b/Project Pattern/pattern_10.py index e2601f2..e8b7635 100644 --- a/Project Pattern/pattern_10.py +++ b/Project Pattern/pattern_10.py @@ -1,15 +1,15 @@ def pattern_ten(strings): '''Pattern ten - K - K A - K A T - K A T H - K A T H M - K A T H M A - K A T H M A N - K A T H M A N D - K A T H M A N D U + K + K A + K A T + K A T H + K A T H M + K A T H M A + K A T H M A N + K A T H M A N D + K A T H M A N D U ''' if not str(strings).isalpha(): diff --git a/Project Pattern/pattern_13.py b/Project Pattern/pattern_13.py index e3b90bb..c62978c 100644 --- a/Project Pattern/pattern_13.py +++ b/Project Pattern/pattern_13.py @@ -1,15 +1,15 @@ def pattern_thirteen(strings): '''Pattern thirteen - U - D - N - A - M - H - T - A - K + U + D + N + A + M + H + T + A + K ''' if not str(strings).isalpha(): diff --git a/Project Pattern/pattern_14.py b/Project Pattern/pattern_14.py index 1c79e03..50f5aba 100644 --- a/Project Pattern/pattern_14.py +++ b/Project Pattern/pattern_14.py @@ -1,15 +1,15 @@ def pattern_fourteen(strings): '''Pattern fourteen - K + K + A + T + H + M A - T - H - M - A - N - D - U + N + D + U ''' if not str(strings).isalpha(): diff --git a/Project Pattern/pattern_24.py b/Project Pattern/pattern_24.py index 6cff585..55b2f97 100644 --- a/Project Pattern/pattern_24.py +++ b/Project Pattern/pattern_24.py @@ -1,12 +1,13 @@ def pattern_twenty_four(string): '''Pattern twenty_four - ***** - * - * - **** - * - * - ***** + + ***** + * + * + **** + * + * + ***** ''' for i in range(7): diff --git a/Project Pattern/pattern_25.py b/Project Pattern/pattern_25.py index b58eea2..17f7de0 100644 --- a/Project Pattern/pattern_25.py +++ b/Project Pattern/pattern_25.py @@ -1,5 +1,6 @@ def pattern_twenty_five(string): '''Pattern twenty_five + **** * * * * diff --git a/Project Pattern/pattern_26.py b/Project Pattern/pattern_26.py index 85dee69..2261282 100644 --- a/Project Pattern/pattern_26.py +++ b/Project Pattern/pattern_26.py @@ -1,5 +1,6 @@ def pattern_twenty_six(string): '''Pattern twenty_six + *** * * * diff --git a/Project Pattern/pattern_27.py b/Project Pattern/pattern_27.py index c6ca18b..d10a58c 100644 --- a/Project Pattern/pattern_27.py +++ b/Project Pattern/pattern_27.py @@ -1,5 +1,6 @@ def pattern_twenty_seven(string): '''Pattern twenty_seven + * * * diff --git a/Project Pattern/pattern_29.py b/Project Pattern/pattern_29.py index 6a10647..d523aa3 100644 --- a/Project Pattern/pattern_29.py +++ b/Project Pattern/pattern_29.py @@ -1,5 +1,6 @@ def pattern_twenty_nine(string): '''Pattern twenty_nine + *** * * * * diff --git a/Project Pattern/pattern_30.py b/Project Pattern/pattern_30.py index cea80bc..b086fdd 100644 --- a/Project Pattern/pattern_30.py +++ b/Project Pattern/pattern_30.py @@ -1,5 +1,6 @@ def pattern_thirty(string): '''Pattern thirty + **** * * * * diff --git a/Project Pattern/pattern_32.py b/Project Pattern/pattern_32.py index 9a53685..1747d05 100644 --- a/Project Pattern/pattern_32.py +++ b/Project Pattern/pattern_32.py @@ -33,4 +33,4 @@ def pattern_thirty_one(string, steps): if __name__ == '__main__': - pattern_thirty_one('|||||', 20) + pattern_thirty_one('*', 20) diff --git a/Project Pattern/pattern_33.py b/Project Pattern/pattern_33.py new file mode 100644 index 0000000..0142535 --- /dev/null +++ b/Project Pattern/pattern_33.py @@ -0,0 +1,24 @@ +def pattern_thirty_three(): + '''Pattern thirty_three + + 1 1 + 12 21 + 123 321 + 1234 4321 + 123454321 + ''' + + num = '12345' + + for i in range(5): + slice = num[0: i + 1] + + if i < 4: + print(f'{slice.ljust(8 - i)}{slice[::-1]}') + + else: + print(f'{slice.ljust(8 - i)}{slice[:-1][::-1]}') + + +if __name__ == '__main__': + pattern_thirty_three() diff --git a/Project Pattern/pattern_34.py b/Project Pattern/pattern_34.py new file mode 100644 index 0000000..1632eea --- /dev/null +++ b/Project Pattern/pattern_34.py @@ -0,0 +1,31 @@ +def pattern_thirty_four(strings, steps): + '''Pattern thirty_four + + * + * * + * * * + * * * * + * * * * * + * * * * * * + * * * * * * + * * * * * * + * * * * * + * * * * + * * * + * * + * + ''' + + for i in range(1, steps + 1): + multiplying_strings = strings * i # Multiplying the given string with 'i' to get the same character + joining_strings = ' '.join(multiplying_strings).center(steps * 4) # Joining the multiplied character 'a' with spaces and placing them to the center + print(joining_strings.rstrip()) # Stripping spaces of right side + + for i in range(steps + 1, 0, -1): + multiplying_strings = strings * i # Multiplying the given string with 'i' to get the same character + joining_strings = ' '.join(multiplying_strings).center(steps * 4) # Joining the multiplied character 'a' with spaces and placing them to the center + print(joining_strings.rstrip()) # Stripping spaces of right side + + +if __name__ == '__main__': + pattern_thirty_four('*', 6) diff --git a/Project Pattern/pattern_35.py b/Project Pattern/pattern_35.py new file mode 100644 index 0000000..b2b4943 --- /dev/null +++ b/Project Pattern/pattern_35.py @@ -0,0 +1,30 @@ +def pattern_thirty_five(strings, steps): + '''Pattern thirty_five + + * * * * * * + * * * * * + * * * * + * * * + * * + * + * + * * + * * * + * * * * + * * * * * + * * * * * * + ''' + + for i in range(steps, 0, -1): + multiplying_strings = strings * i # Multiplying the given string with 'i' to get the same character + joining_strings = ' '.join(multiplying_strings).center(steps * 4) # Joining the multiplied character 'a' with spaces and placing them to the center + print(joining_strings.rstrip()) # Stripping spaces of right side + + for i in range(1, steps + 1): + multiplying_strings = strings * i # Multiplying the given string with 'i' to get the same character + joining_strings = ' '.join(multiplying_strings).center(steps * 4) # Joining the multiplied character 'a' with spaces and placing them to the center + print(joining_strings.rstrip()) # Stripping spaces of right side + + +if __name__ == '__main__': + pattern_thirty_five('*', 6) diff --git a/Project Pattern/pattern_36.py b/Project Pattern/pattern_36.py new file mode 100644 index 0000000..1ea8209 --- /dev/null +++ b/Project Pattern/pattern_36.py @@ -0,0 +1,27 @@ +def pattern_thirty_six(): + '''Pattern thirty_six + + 1 + 1 2 + 1 3 + 1 4 + 1 2 3 4 5 + ''' + num = '12345' + + for i in range(1, 6): + x = num[:i] + + if i in range(2, 5): + space = 2 * (i - 1) - i # using 2*n - 1 for getting required space where n = 1, 2, 3, .... and here n = i - 1 + print(x[0] + ' ' * space + x[-1]) + + elif i == 5: + print(' '.join(num)) + + else: + print(x) + + +if __name__ == '__main__': + pattern_thirty_six() diff --git a/Project Pattern/pattern_37.py b/Project Pattern/pattern_37.py new file mode 100644 index 0000000..e881fa8 --- /dev/null +++ b/Project Pattern/pattern_37.py @@ -0,0 +1,27 @@ +def pattern_thirty_seven(): + '''Pattern thirty_seven + + 1 2 3 4 5 + 2 5 + 3 5 + 4 5 + 5 + ''' + + num = '12345' + + for i in range(1, 6): + if i == 1: + print(' '.join(num)) + + elif i in range(2, 5): + space = -2 * i + 9 # using -2*n + 9 for getting required space where n = 1, 2, 3, .... and here n = i + output = num[i - 1] + ' ' * space + '5' + print(output) + + else: + print('5') + + +if __name__ == '__main__': + pattern_thirty_seven() diff --git a/Project Pattern/pattern_38.py b/Project Pattern/pattern_38.py new file mode 100644 index 0000000..06e0785 --- /dev/null +++ b/Project Pattern/pattern_38.py @@ -0,0 +1,30 @@ +def pattern_thirty_eight(): + '''Pattern thirty_eight + + 1 + 1 2 + 1 3 + 1 4 + 1 2 3 4 5 + ''' + + num = '12345' + + for i in range(5): + if i in range(1, 4): + space = ' ' * (2 * i - 1) + temp = num[:i + 1] + + output = space.join(temp[0] + temp[-1]) + print(output.center(30)) + + elif i == 4: + output = ' '.join(num) + print(output.center(30)) + + else: + print('1'.center(30)) + + +if __name__ == '__main__': + pattern_thirty_eight() diff --git a/Project Pattern/pattern_39.py b/Project Pattern/pattern_39.py new file mode 100644 index 0000000..b28d7ec --- /dev/null +++ b/Project Pattern/pattern_39.py @@ -0,0 +1,24 @@ +def pattern_thirty_nine(): + '''Pattern thirty_nine + + 1 + 2 3 2 + 3 4 5 4 3 + 4 5 6 7 6 5 4 + 5 6 7 8 9 8 7 6 5 + ''' + + num = '123456789' + + for i in range(5): + if i == 0: + print('1'.center(30)) + + else: + temp = num[i: i * 2 + 1] + output = temp + temp[:i][::-1] + print(' '.join(output).center(30)) + + +if __name__ == '__main__': + pattern_thirty_nine()