Skip to content

Uploaded a shape directory #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions assets/Shapes/right_angle_tringle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
def Square(s):
for i in range(s):
if i == 0: # First row
print('*')
elif i == s - 1: # Last row
print('* ' * s)
else: # Middle rows
print('*' + ' ' * (2 * i - 1) + '*')
def check_length():
while True:
length = input('Enter the length of the triangle: ')
if length.isdigit():
length = int(length)
if length > 1:
Square(length)
else:
print('Length must be greater than one.')
else:
print('Please enter a digit.')


check_length()

if __name__ == '__main__':
check_length()


32 changes: 32 additions & 0 deletions assets/Shapes/square.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# simple square
def accept_square_size(): # A function to accept square size
size = input('Enter the size of the square: ')
return size


def validate_square_size(): # A function to validate square size
size = accept_square_size()

if size.isdigit():
size = int(size)
if size > 1:
draw_square(size)
else:
print('Size must be greater than one!')
else:
print('Size must be a digit!')

def draw_square(size): # A function to draw a square

for i in range(size):
if i == size-1 or i == 0:
print('* '*size)
else:
print('* '+ ' '*(size-2)+ '*')

def display_square(): # A function that displays the square
validate_square_size()


if __name__ == '__main__': # main function
display_square()
Loading