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 another possible version of your mathy problem:</p>

<pre><code>import math


def heron(a, b, c):
    return 0.25 * math.sqrt((a + (b + c)) * (c - (a - b)) * (c + (a - b)) * (a + (b - c)))

if __name__ == "__main__":
    print()
    print("Triangle Area Program")
    print()
    print()

    try:
        description = "Enter three lengths separated by commas: "
        sides = sorted(map(float, input(description).split(',')))

        if (sides[1] + sides[2]) &lt; sides[0]:
            print("A triangle cannot be formed.")
        else:
            a, b, c = sides
            print("Area of triangle {0}-{1}-{2} is {3:.4f}".format(
                sides[0], sides[1], sides[2], heron(a, b, c)))
    except Exception as e:
        print("Check your input!!!")
        print("--&gt; Error: {0}".format(e))
</code></pre>

<p>Few notes about this version:</p>

<ul>
<li>It's parsing your floating-point input values and sorting at the same time, that way you can check directly whether a triangle can be formed or not</li>
<li>It's not using the naive heron formula, instead is using another one which is <a href="https://en.wikipedia.org/wiki/Heron%27s_formula" rel="nofollow">numerically stable</a></li>
</ul>

<p>I've decided to give you another version because in the comments you'll find some good advices about yours</p>

python python-3.x