8000 Print Pattern of letter D · avinashn/programminginpython.com@4f148b2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f148b2

Browse files
committed
Print Pattern of letter D
1 parent e7ca2a1 commit 4f148b2

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

patterns/Pattern-D.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
__author__ = 'Avinash'
2+
3+
4+
# Python3 program to print alphabet pattern D
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 row in range(n):
18+
19+
# Inner for loop columns
20+
for column in range(n - 2):
21+
22+
# prints first and last row
23+
if (
24+
((row == 0 or row == n-1) and (0 < column < n-3)) or
25+
26+
# prints first column
27+
column == 0 or
28+
29+
# prints last column
30+
column == n - 3 and (row != 0 and row != n - 1)
31+
):
32+
print("*", end=" ")
33+
else:
34+
print(" ", end="")
35+
print()
36+
37+
# Size of the letter
38+
num = int(input("Enter the size \t"))
39+
40+
if num < 8:
41+
print("Enter a number atleast 8")
42+
else:
43+
print_pattern(num)

0 commit comments

Comments
 (0)
0