We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4c180ea commit 9666abfCopy full SHA for 9666abf
patterns/pattern-k.py
@@ -0,0 +1,47 @@
1
+__author__ = 'Avinash'
2
+
3
4
+# Python3 program to print alphabet pattern K
5
6
+# * *
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+def print_pattern(n):
21
22
+ i = 0
23
+ j = n//2
24
+ # Outer for loop for number of rows
25
+ for rows in range(n):
26
27
+ # Inner for loop columns
28
+ for columns in range(n):
29
30
+ # prints first and last column
31
+ if columns == 0 or (rows == (columns+(n//3)) and columns > 0):
32
+ print("*", end=" ")
33
+ elif rows == i and columns == j:
34
35
+ i = i+1
36
+ j = j-1
37
+ else:
38
+ print(" ", end=" ")
39
+ print()
40
41
42
+size = int(input("Enter size: \t"))
43
44
+if size < 8:
45
+ print("Enter a size greater than 8")
46
+else:
47
+ print_pattern(size)
0 commit comments