-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathpattern-k.py
47 lines (36 loc) · 874 Bytes
/
pattern-k.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
__author__ = 'Avinash'
# Python3 program to print alphabet pattern K
# * *
# * *
# * *
# * *
# * *
# * *
# * *
# * *
# * *
# * *
# * *
# * *
def print_pattern(n):
i = 0
j = n//2
# Outer for loop for number of rows
for rows in range(n):
# Inner for loop columns
for columns in range(n):
# prints first and last column
if columns == 0 or (rows == (columns+(n//3)) and columns > 0):
print("*", end=" ")
elif rows == i and columns == j:
print("*", end=" ")
i = i+1
j = j-1
else:
print(" ", end=" ")
print()
size = int(input("Enter size: \t"))
if size < 8:
print("Enter a size greater than 8")
else:
print_pattern(size)