Advertisement
g0thy

Triangle

Nov 25th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. #Calculate the area of a triangle
  2.  
  3. #Create a function to calculate the area of a trinagle
  4. def triangleArea(h, w):
  5.     area=(h*w*0.5)
  6.     return area
  7.  
  8. #Input the paramaters
  9. tHeight = input('Triangle Height: ')
  10. tWidth = input('Triangle Width: ')
  11.  
  12. #convert to floating point numbers
  13. fHeight = float(tHeight)
  14. fWidth = float(tWidth)
  15.  
  16. #Call the function
  17. tArea = triangleArea(fHeight, fWidth)
  18. print('The area of the triangle is = ', tArea)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement