Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Create a function that asks the user for the
- height and base of a triangle, and then calculates
- and prints out its area.
- """
- def area_of_triangle():
- area = height * base / 2
- print("The area of a triangle with a height of " + str(height) + " and a base of " + str(base) + " is " + str(area) )
- print(f"The area of a triangle with a height of {height} and a base of {base} is {area}") ## using f string
- height = float(input("Please enter the height of the triangle > "))
- base = float(input("Please enter the base of the triangle > "))
- area_of_triangle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement