DragonBowl

polygon area calulator

Mar 10th, 2023
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.43 KB | Source Code | 0 0
  1. import math
  2. def welcome():
  3.     print("Polygon are calculator by dragonbowl")
  4.     sorr()
  5. def sorr():
  6.     sor = input("Is it a square or a rectangle? S for Square or R for rectangle: ")
  7.    
  8.     if sor.lower() == "s":
  9.         shape = "square"
  10.         square()
  11.  
  12.     elif sor.lower() == "r":
  13.         shape = "rectangle"
  14.         rectangle()
  15.  
  16.     else:
  17.         print("Invalid input. Please enter S or R.")
  18.         sorr()
  19.    
  20.     return shape
  21. def square():
  22.     width = int(input("Enter the width of the square: "))
  23.  
  24.     length = int(input("Enter the length of the square: "))
  25.  
  26.     area = width * length
  27.  
  28.     dbfsqr = ((width * width) + (length * length))
  29.     diagonal = math.sqrt(dbfsqr)
  30.     print('''
  31.    Your Width is ''',width,'''
  32.    Your Length is ''', length ,'''
  33.    The length of your diagonal is ''',diagonal,'''
  34.    
  35.     ''')
  36.  
  37.     for i in range(width):
  38.         print(" *"*width)
  39.     sorr()
  40. def rectangle():
  41.     width = int(input("Enter the width of the rectangle: "))
  42.  
  43.     length = int(input("Enter the length of the rectangle: "))
  44.  
  45.     area = width * length
  46.  
  47.     dbfsqr = ((width * width) + (length * length))
  48.     diagonal = math.sqrt(dbfsqr)
  49.     print('''
  50.    Your Width is ''',width,'''
  51.    Your Length is ''', length ,'''
  52.    The length of your diagonal is ''',diagonal,'''
  53.  
  54.    
  55.     ''')
  56.     line1=(width*(" *"))
  57.     for i in range(length):
  58.         print(line1)
  59.        
  60.     sorr()
  61. welcome()
Advertisement
Add Comment
Please, Sign In to add comment