Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def welcome():
- print("Polygon are calculator by dragonbowl")
- sorr()
- def sorr():
- sor = input("Is it a square or a rectangle? S for Square or R for rectangle: ")
- if sor.lower() == "s":
- shape = "square"
- square()
- elif sor.lower() == "r":
- shape = "rectangle"
- rectangle()
- else:
- print("Invalid input. Please enter S or R.")
- sorr()
- return shape
- def square():
- width = int(input("Enter the width of the square: "))
- length = int(input("Enter the length of the square: "))
- area = width * length
- dbfsqr = ((width * width) + (length * length))
- diagonal = math.sqrt(dbfsqr)
- print('''
- Your Width is ''',width,'''
- Your Length is ''', length ,'''
- The length of your diagonal is ''',diagonal,'''
- ''')
- for i in range(width):
- print(" *"*width)
- sorr()
- def rectangle():
- width = int(input("Enter the width of the rectangle: "))
- length = int(input("Enter the length of the rectangle: "))
- area = width * length
- dbfsqr = ((width * width) + (length * length))
- diagonal = math.sqrt(dbfsqr)
- print('''
- Your Width is ''',width,'''
- Your Length is ''', length ,'''
- The length of your diagonal is ''',diagonal,'''
- ''')
- line1=(width*(" *"))
- for i in range(length):
- print(line1)
- sorr()
- welcome()
Advertisement
Add Comment
Please, Sign In to add comment