Skip to content

Commit 07bdefb

Browse files
committed
Pattern of letter B in Python
1 parent 742bb06 commit 07bdefb

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Diff for: patterns/pattern-b.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
__author__ = 'Avinash'
2+
3+
# Python3 program to print alphabet B pattern
4+
5+
# Function to display alphabet pattern
6+
7+
8+
def print_pattern(n):
9+
# Outer for loop for number of lines(rows)
10+
for i in range(n):
11+
12+
# Inner for loop for logic execution
13+
for j in range(n + 1):
14+
15+
# prints two column lines
16+
if ((j == 0 or j == n) or
17+
18+
# print first line of alphabet
19+
i == 0 and j != 0 and j != n or
20+
21+
# prints last line
22+
i == n - 1 or
23+
24+
# prints middle line
25+
i == n // 2):
26+
print("*", end="")
27+
else:
28+
print(" ", end="")
29+
30+
print()
31+
32+
33+
# Size of the letter
34+
num = int(input("Enter the size: \t "))
35+
36+
if num > 7:
37+
print_pattern(num)
38+
else:
39+
print("Enter a size minimum of 8")

0 commit comments

Comments
 (0)