AlexParry

Triangle area

Nov 25th, 2019
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. def tri_area(base,height):
  2.     BXH = base * height
  3.     calc_area = BXH / 2 # calc_area is local so can only be accessed inside the tri_area() function
  4.     return calc_area # to output the value of calc_area the value is returned
  5.  
  6. area = tri_area(int(input("Please enter the base of the triangle.  ")), int(input("Please enter the height of the triangle.  "))) #Asks the user for custom dimensions, and stores them as integers
  7. print("The area of the triangle is:", area) #Outputs the custom dimensions
Advertisement
Add Comment
Please, Sign In to add comment