From ca8ae1ebb3f83661a3669475a3fece1c97739219 Mon Sep 17 00:00:00 2001 From: Hasanul Banna Himel <84923500+Hasanul-Banna-Himel@users.noreply.github.com> Date: Fri, 6 Oct 2023 11:33:34 +0600 Subject: [PATCH 1/2] Patterns added --- .../Python_Programs/pattern.py | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Program's_Contributed_By_Contributors/Python_Programs/pattern.py diff --git a/Program's_Contributed_By_Contributors/Python_Programs/pattern.py b/Program's_Contributed_By_Contributors/Python_Programs/pattern.py new file mode 100644 index 0000000000..7b9f6c6218 --- /dev/null +++ b/Program's_Contributed_By_Contributors/Python_Programs/pattern.py @@ -0,0 +1,79 @@ +val = int(input("Give your value in stars: ")) +#for square +def square(num): + num = val + for i in range(num): + for j in range(num): + print("*", end = " ") + print() +#increasing triangle +def increasing_triangle(num): + num = val + for i in range(num): + for j in range(i+1): + print("*", end = " ") + print() +#decreasing triangle +def decreasing_triangle(num): + num = val + for i in range(num): + for j in range(i,n): + print("*", end = " ") + print() +#right sided triangle (increasing star) +def right_sided_triangle_inc(num): + num = val + for i in range(num): + for j in range(i,num): + print("",end = " ") + for j in range(i+1): + print("*", end = " ") + print() +#right sided triangle (decreasing star) +def right_sided_triangle_dec(num): + num = val + for i in range(num): + for j in range(i+1): + print("",end = " ") + for j in range(i,num): + print("*", end = " ") + print() +#hill pattern +def hill_pattern(num): + num = val + for i in range(num): + for j in range(i,num): + print(" ", end = " ") + for j in range(i): + print("*",end = " ") + for j in range(i+1): + print("*",end = " ") + print() +#reverse hill pattern +def reverse_hill_pattern(num): + num = val + for i in range(num): + for j in range(i+1): + print(" ", end = " ") + for j in range(i,n-1): + print("*",end = " ") + for j in range(i,n): + print("*",end = " ") + print() +#diamond pattern +def diamond(num): + num = val + for i in range(num): + print(" " * (num - i), "*" * (2*i + 1)) + for i in range(num - 2, -1, -1): + print(" " * (num - i), "*" * (2*i + 1)) + +#comment out other lines below here while printing one funnction +square(val) #square +increasing_triangle(val) #increasing triangle +decreasing_triangle(val) #decreasing triangle +right_sided_triangle_inc(val) #right sided triangle (increasing star) +right_sided_triangle_dec(val) #right sided triangle (decreasing star) +hill_pattern(val) #hill pattern +reverse_hill_pattern(val) #reverse hill pattern +diamond(val) #diamond pattern \ No newline at end of file From ceb325f90d65e9914a76dff13a35ac8d9812ceb1 Mon Sep 17 00:00:00 2001 From: Hasanul Banna Himel <84923500+Hasanul-Banna-Himel@users.noreply.github.com> Date: Fri, 6 Oct 2023 11:36:30 +0600 Subject: [PATCH 2/2] Patterns added