Skip to content

Commit ab80163

Browse files
authored
Merge pull request openAOD#887 from eshan1925/patch-1
Committed codes for 10 patterns
2 parents 1efa996 + c26beee commit ab80163

10 files changed

+276
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
def pattern(n):
2+
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3+
counter = n
4+
for i in range(n,0,-1):
5+
counteri = counter-1
6+
for j in range(0,i):
7+
print(alpha[counteri],end=" ")
8+
counteri = counteri-1
9+
print("")
10+
counter = counter + 1
11+
12+
print("Enter the number of rows: ")
13+
n = int(input())
14+
pattern(n)
15+
16+
17+
# OUTPUT
18+
19+
# Enter the number of rows:
20+
# 5
21+
# E D C B A
22+
# F E D C
23+
# G F E
24+
# H G
25+
# I
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
def pattern(n):
2+
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3+
counter = n
4+
for i in range(n,0,-1):
5+
counteri = counter-1
6+
for j in range(0,i):
7+
print(alpha[counteri],end=" ")
8+
counteri = counteri+1
9+
print("")
10+
counter = counter - 1
11+
12+
print("Enter the number of rows: ")
13+
n = int(input())
14+
pattern(n)
15+
16+
17+
# OUTPUT
18+
19+
# Enter the number of rows:
20+
# 5
21+
# E F G H I
22+
# D E F G
23+
# C D E
24+
# B C
25+
# A
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
def pattern(n):
2+
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3+
counter = 0
4+
for i in range(0,n+1):
5+
for j in range(0,i):
6+
if(counter>25):
7+
counter = counter - 26
8+
print(alpha[counter],end=" ")
9+
counter=counter+1
10+
print("")
11+
12+
print("Enter the number of rows: ")
13+
n = int(input())
14+
pattern(n)
15+
16+
17+
# OUTPUT
18+
19+
# Enter the number of rows:
20+
# 5
21+
22+
# A
23+
# B C
24+
# D E F
25+
# G H I J
26+
# K L M N O
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
def pypart2(n):
2+
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3+
k = 2*n - 2
4+
counter = 0
5+
for i in range(0, n):
6+
for j in range(0, k):
7+
print(end=" ")
8+
k = k - 2
9+
10+
for j in range(0, i+1):
11+
print(alpha[counter], end=" ")
12+
counter=counter+1
13+
print("\r")
14+
15+
16+
print("Enter the number of rows: ")
17+
n = int(input())
18+
pypart2(n)
19+
20+
21+
22+
# OUTPUT
23+
24+
# Enter the number of rows:
25+
# 5
26+
# A
27+
# B B
28+
# C C C
29+
# D D D D
30+
# E E E E E
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
def pypart2(n):
2+
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3+
k = 2*n - 2
4+
flag = n-1
5+
for i in range(0, n):
6+
for j in range(0, k):
7+
print(end=" ")
8+
k = k - 2
9+
counter = flag
10+
for j in range(0, i+1):
11+
print(alpha[counter], end=" ")
12+
counter =counter + 1
13+
flag = flag -1
14+
print("\r")
15+
16+
17+
print("Enter the number of rows: ")
18+
n = int(input())
19+
pypart2(n)
20+
21+
22+
23+
# OUTPUT
24+
25+
# Enter the number of rows:
26+
# 5
27+
# E
28+
# D E
29+
# C D E
30+
# B C D E
31+
# A B C D E
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
def pypart2(n):
2+
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3+
k = 2*n - 2
4+
flag = n-1
5+
for i in range(0, n):
6+
for j in range(0, k):
7+
print(end=" ")
8+
k = k - 2
9+
counter = flag
10+
for j in range(0, i+1):
11+
print(alpha[counter], end=" ")
12+
flag = flag -1
13+
print("\r")
14+
15+
16+
print("Enter the number of rows: ")
17+
n = int(input())
18+
pypart2(n)
19+
20+
21+
22+
# OUTPUT
23+
24+
# Enter the number of rows:
25+
# 5
26+
# E
27+
# D D
28+
# C C C
29+
# B B B B
30+
# A A A A A
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
def pattern(n):
2+
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3+
countj = 0
4+
for i in range(0,n):
5+
counti = 0
6+
for j in range(0,n):
7+
flag = counti+countj
8+
if(flag>25):
9+
flag = flag - 26
10+
print(alpha[flag],end=" ")
11+
counti = counti+5
12+
print("\r")
13+
countj=countj+1
14+
15+
print("Enter the number of rows: ")
16+
n = int(input())
17+
pattern(n)
18+
19+
#OUTPUT
20+
21+
# Enter the number of rows:
22+
# 5
23+
# A F K P U
24+
# B G L Q V
25+
# C H M R W
26+
# D I N S X
27+
# E J O T Y
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
def pattern(n):
2+
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3+
countj = 0
4+
for i in range(0,n):
5+
counti = 4
6+
for j in range(0,n):
7+
flag = counti+countj
8+
if(flag>25):
9+
flag = flag - 26
10+
print(alpha[flag],end=" ")
11+
counti = counti+5
12+
print("\r")
13+
countj=countj-1
14+
15+
print("Enter the number of rows: ")
16+
n = int(input())
17+
pattern(n)
18+
19+
20+
# OUTPUT
21+
22+
# Enter the number of rows:
23+
# 5
24+
# E J O T Y
25+
# D I N S X
26+
# C H M R W
27+
# B G L Q V
28+
# A F K P U

Pyramid Patterns/pyramidpattern61.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
def triangle(n):
2+
k = n - 1
3+
for i in range(0, n):
4+
for j in range(0, k):
5+
print(end=" ")
6+
k = k - 1
7+
for j in range(0, i+1):
8+
if(i%2!=0):
9+
print("* ", end="")
10+
else:
11+
print("# ", end="")
12+
print("\r")
13+
14+
15+
print("Enter the number of rows: ")
16+
n = int(input())
17+
triangle(n)
18+
19+
20+
#OUTPUT
21+
22+
# Enter the number of rows:
23+
# 5
24+
# #
25+
# * *
26+
# # # #
27+
# * * * *
28+
# # # # # #

Symbol Patterns/symbolicpattern162.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
print("Enter the number of rows: ")
2+
n = int(input())
3+
n = int(n/2)
4+
spaces = n + (n - 1)
5+
counter = 1
6+
count = 0
7+
for i in range(0, n):
8+
for i in range(2):
9+
for k in range(0, spaces):
10+
print(" ", end="")
11+
for j in range(0, counter):
12+
print("*", end=" ")
13+
print()
14+
counter = counter + 2
15+
spaces = spaces - 2
16+
17+
# EXAMPLE OUTPUT
18+
19+
# Enter the number of rows:
20+
# 6
21+
# *
22+
# *
23+
# * * *
24+
# * * *
25+
# * * * * *
26+
# * * * * *

0 commit comments

Comments
 (0)