Anon248 Anon248 - 2 years ago 81
Python Question

Anyone Know How to Calculate the Area/Perimeter/Height of a Triangle?

This is what I've got so far:

a = float(input('Please Enter the First side of a Triangle: '))

b = float(input('Please Enter the Second side of a Triangle: '))

c = float(input('Please Enter the Third side of a Triangle: '))

I still have to calculate the height. Everything else seems to be working now :D

Answer Source

In mathematics, the triangle inequality states that for any triangle, the sum of the lengths of any two sides must be greater than or equal to the length of the remaining side.

a, b, c = 1, 1, 1 # sides of a triangle
if a + b >= c and b + c >= a and c + a >= b:
    # calculate area and height here
    print('Not a valid triangle')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download