-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDiamond.py
More file actions
51 lines (44 loc) · 774 Bytes
/
Copy pathDiamond.py
File metadata and controls
51 lines (44 loc) · 774 Bytes
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
48
49
50
51
#how to print the following pattern of any size
'''
size: 10
*
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
*
'''
#to define size of pattern
n = int(input('Enter the size: '))
#Increasing decreasing parameter
a = 0
b = 2*n-2
c = d = n-1
#pattern
pat = '*'
#printing pattern
#1st A pattern
for i in range(n-1):
for j in range(2*n-1):
print(pat if j in (c, d) else ' ', end= '')
c+=1; d-=1
print()
#2nd V pattern
for i in range(n):
for j in range(2*n-1):
print(pat if j in (a, b) else ' ', end= '')
a+=1; b-=1
print()