Skip to content

Commit

Permalink
Merge pull request fineanmol#5797 from Hasanul-Banna-Himel/master
Browse files Browse the repository at this point in the history
Patterns added
  • Loading branch information
fineanmol authored Oct 6, 2023
2 parents 0fbe331 + ceb325f commit 8600927
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions Program's_Contributed_By_Contributors/Python_Programs/pattern.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8600927

Please sign in to comment.