Skip to content

Commit 223154b

Browse files
authored
Add files via upload
1 parent 80478db commit 223154b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# simple square
2+
def accept_square_size(): # A function to accept square size
3+
size = input('Enter the size of the square: ')
4+
return size
5+
6+
7+
def validate_square_size(): # A function to validate square size
8+
size = accept_square_size()
9+
10+
if size.isdigit():
11+
size = int(size)
12+
if size > 1:
13+
draw_square(size)
14+
else:
15+
print('Size must be greater than one!')
16+
else:
17+
print('Size must be a digit!')
18+
19+
def draw_square(size): # A function to draw a square
20+
21+
for i in range(size):
22+
if i == size-1 or i == 0:
23+
print('* '*size)
24+
else:
25+
print('* '+ ' '*(size-2)+ '*')
26+
27+
def display_square(): # A function that displays the square
28+
validate_square_size()
29+
30+
31+
if __name__ == '__main__': # main function
32+
display_square()

0 commit comments

Comments
 (0)