Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def triangle(size):
- # triangle
- #
- # *
- # * *
- # * * *
- # * * * *
- # * * * * *
- row = 1
- while row <= size:
- print("* " * row)
- row += 1
- def rectangle(height, width):
- # Rectangle
- #
- # * * * * * * *
- # * * * * * * *
- # * * * * * * *
- row = 1
- while row <= height:
- print("* " * width)
- row += 1
- def unfilled_rectangle(height, width):
- # Unfilled rectangle
- #
- # 1 2 3 4 5 6 7
- # * * * * * * * 1
- # * * 2
- # * * 3
- # * * * * * * * 4
- row = 1
- while row <= height:
- if row == 1 or row == height:
- print("* " * width)
- else:
- print("* " + (" " * (width - 2)) + "* ")
- row += 1
- print("Shape (triangle, [unfilled] square or [unfilled] rectangle)?")
- shape = input()
- print("Height of the shape?")
- height = input()
- height = int(height)
- if shape == "triangle":
- triangle(height)
- elif shape == "rectangle":
- print("Width of the rectangle?")
- width = input()
- width = int(width)
- rectangle(height, width)
- elif shape == "unfilled rectangle":
- print("Width of the rectangle?")
- width = input()
- width = int(width)
- unfilled_rectangle(height, width)
- elif shape == "square":
- rectangle(height, height)
- elif shape == "unfilled square":
- unfilled_rectangle(height, height)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement