Advertisement
HristoBaychev

Area of Figures

Jan 28th, 2023
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. import math
  2.  
  3. figures = str(input('Enter the shape of figure: '))
  4. area = 0.00
  5.  
  6. if figures == 'square':
  7.     sideA = float(input('Enter the length of side: '))
  8.     area = sideA * sideA
  9.     print(f'{area:.3f}')
  10. elif figures == 'rectangle':
  11.     sideA = float(input('Enter the length of first side: '))
  12.     sideB = float(input('Enter the length of second side: '))
  13.     area = sideA * sideB
  14.     print(f'{area:.3f}')
  15. elif figures == 'circle':
  16.     radius = float(input('Enter the radius of circle: '))
  17.     area = math.pi * radius * radius
  18.     print(f'{area:.3f}')
  19. elif figures == 'triangle':
  20.     sideA = float(input('Enter the height: '))
  21.     sideB = float(input('Enter the length: '))
  22.     area = (sideA * sideB) / 2
  23.     print(f'{area:.3f}')
  24.  
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement