8000 Python Program to print pattern of letter H · avinashn/programminginpython.com@306abd0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 306abd0

Browse files
committed
Python Program to print pattern of letter H
1 parent 4f15553 commit 306abd0

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

patterns/Pattern-H.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
__author__ = 'Avinash'
2+
3+
4+
# Python3 program to print alphabet pattern H
5+
6+
# * *
7+
# * *
8+
# * *
9+
# * * * * * *
10+
# * *
11+
# * *
12+
# * *
13+
14+
15+
def print_pattern(n):
16+
# Outer for loop for number of rows
17+
for rows in range(n):
18+
19+
# Inner for loop columns
20+
for columns in range(n):
21+
22+
# prints first and last column
23+
if ((columns == 0 or columns == n-1) or
24+
# prints middle row
25+
(rows == n // 2)
26+
):
27+
print("*", end=" ")
28+
else:
29+
print(" ", end=" ")
30+
print()
31+
32+
33+
size = int(input("Enter size: \t"))
34+
35+
if size < 8:
36+
print("Enter a size greater than 8")
37+
else:
38+
print_pattern(size)

0 commit comments

Comments
 (0)
0