Advertisement
timber101

Area of triangle

Dec 10th, 2020
811
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. """
  2. Create a function that asks the user for the
  3. height and base of a triangle, and then calculates
  4. and prints out its area.
  5. """
  6.  
  7. def area_of_triangle():
  8.     area = height * base / 2
  9.     print("The area of a triangle with a height of " + str(height) + " and a base of " + str(base) + " is " + str(area) )
  10.     print(f"The area of a triangle with a height of {height} and a base of {base}  is {area}")  ## using f string
  11.  
  12. height = float(input("Please enter the height of the triangle > "))
  13. base = float(input("Please enter the base of the triangle >  "))
  14.  
  15. area_of_triangle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement