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

Skip to content

Commit 4c180ea

Browse files
committed
Python Program to print pattern of letter J
1 parent 6a3177d commit 4c180ea

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

patterns/Pattern-J.py

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

0 commit comments

Comments
 (0)
0