Advertisement
here2share

# area_of_triangle_by_sides.py

Feb 23rd, 2020
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. # area_of_triangle_by_sides.py
  2.  
  3. a = 5
  4. b = 6
  5. c = 7
  6.  
  7. # Uncomment below to take inputs from the user
  8. a = float(input('Enter first side: '))
  9. b = float(input('Enter second side: '))
  10. c = float(input('Enter third side: '))
  11.  
  12. # calculate the semi-perimeter
  13. s = (a + b + c) / 2
  14.  
  15. # calculate the area
  16. area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
  17. print('The area of the triangle is %0.2f' %area)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement