-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathasciiart.py
More file actions
25 lines (21 loc) · 871 Bytes
/
asciiart.py
File metadata and controls
25 lines (21 loc) · 871 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
def draw_cube(size):
# Draw the top of the cube
print(" " * (size // 2) + "+" + "-" * size + "+")
for i in range(size // 2):
print(" " * ((size // 2) - i - 1) + "/" + " " * size + "/" + "|")
# Draw the front and side of the cube
for i in range(size):
if i < size - 1:
print("+" + "-" * size + "+" + " " * (size // 2 - i) + "|")
else:
print("+" + "-" * size + "+")
for j in range(size // 2):
if i < size - 1:
print("|" + " " * size + "|" + " " * (size // 2 - j - 1) + "+")
else:
print("|" + " " * size + "|" + " " * (size // 2 - j - 1) + "/")
# Draw the bottom of the cube
for i in range(size // 2):
print(" " * i + "+" + "-" * size + "+")
# Call the function to draw a cube of a specified size
draw_cube(6)