Finding the Area of a Triangle using if else statements
<p>I am supposed to write a program that prompts the user for the lengths of three sides of a triangle, determines that the three lengths can form a triangle and if so uses Heron's formula to compute the area to 4 digits of precision.This is what I have so far I don't know where or how to put in the math</p>

<pre><code>import math
def main():
    print()
    print("Triangle Area Program")
    print()
    a, b, c = eval(input("Enter three lengths separated by commas: "))
    print()
    s = (a+b+c) / 2.0
    area = sqrt(s*(s-a)*(s-b)*(s-c))
    if a &gt; b:
        a, b = b, a
    if a &gt; c:
        a, c = c, a
    if b &gt; c:
        b, c = c, b
    else:
        a + b &gt; c
        print("A triangle cannot be formed.")

main()
</code></pre>

<p>Here's a slightly modified version of your program that checks if the inputs are compatible in one compound conditional expression and replaces the use of <code>eval</code>:</p>

<pre><code>import math

def main():
    print("\nTriangle Area Program\n")
    a, b, c = map(float, input("Enter three lengths separated by commas: ").split(','))

    if a + b &gt; c and a + c &gt; b and b + c &gt; a:
        s = (a + b + c) / 2.0
        area = math.sqrt(s*(s-a)*(s-b)*(s-c))
        return round(area, 4) # round area to four decimal places
    else:
        raise ValueError("The inputs you entered cannot form a triangle")

if __name__ == '__main__':
    print(main())
</code></pre>

<p>More on avoiding <code>eval</code> when you can <a href="http://stackoverflow.com/questions/1933451/why-should-exec-and-eval-be-avoided">Why should exec() and eval() be avoided?</a></p>

python python-3.x