8000 Pattern of Letter W · raun1997/programminginpython.com@ebf3c2b · GitHub
[go: up one dir, main page]

Skip to content

Commit ebf3c2b

Browse files
committed
Pattern of Letter W
1 parent 4914ed8 commit ebf3c2b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

patterns/Pattern-W.py

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

0 commit comments

Comments
 (0)
0