Skip to content

Commit 04d728d

Browse files
committed
Pattern of Letter S
1 parent a38d553 commit 04d728d

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

patterns/Pattern-S.py

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

0 commit comments

Comments
 (0)