forked from Aatmsaat/Python-Pattern
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcube.py
More file actions
30 lines (22 loc) · 661 Bytes
/
Copy pathcube.py
File metadata and controls
30 lines (22 loc) · 661 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
#cube of any size
#taking the size
size = int(input('Enter the size: '))
size += size%2==0 #change even to odd
half = size//2
for i in range(size+half):
for j in range(size+half):
symbol = ' '
#bottom left square
if i>=half and ((i in [half, size+half-1] and j<size) or (j in [0, size-1])):
symbol = '*'
#top right square
if i<size and j>=half and (i in [0, size-1] or j in [half, half+size-1]):
symbol = '*'
#upper diagonals
if i<=half and ((i+j) in [half, size+half-1]):
symbol = '*'
#lower diagonals
if (i>=size-1 and ((i+j) in [size+half-1, 2*size+half-2])):
symbol = '*'
print(symbol, end = '')
print()