8000 Pattern of Letter Q · mafnan1/programminginpython.com@ccba3d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit ccba3d4

Browse files
committed
Pattern of Letter Q
1 parent c947414 commit ccba3d4

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

patterns/Pattern-Q.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
__author__ = 'Avinash'
2+
3+
4+
# Python3 program to print alphabet pattern Q
5+
6+
# * * * * * *
7+
# * *
8+
# * *
9+
# * *
10+
# * *
11+
# * * *
12+
# * * * * * *
13+
# *
14+
15+
16+
def print_pattern(n):
17+
for row in range(n):
18+
for column in range(n):
19+
if (
20+
# first row
21+
(row == 0 and (column != 0 and column != n - 1)) or
22+
23+
# last row
24+
(row == n - 2 and (column != 0 and column < n - 2)) or
25+
26+
# first column
27+
(column == 0 and (row != 0 and row < n - 2)) or
28+
29+
# last column
30+
(column == n - 1 and (row != 0 and row != n - 2)) or
31+
32+
# Q Tail
33+
((n // 2 < row < n) and (column > n // 2) and (row == column))
34+
):
35+
print("*", end=" ")
36+
else:
37+
print(" ", end=" ")
38+
print()
39+
40+
41+
size = int(input("Enter any size: \t"))
42+
43+
if size < 8:
44+
print("Enter a size minumin of 8")
45+
else:
46+
print_pattern(size)
47+

0 commit comments

Comments
 (0)
0