forked from fineanmol/Hacktoberfest2024
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request fineanmol#5797 from Hasanul-Banna-Himel/master
Patterns added
- Loading branch information
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
Program's_Contributed_By_Contributors/Python_Programs/pattern.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |