Skip to content

Instantly share code, notes, and snippets.

@Shogun89
Created September 11, 2022 20:00
Show Gist options
  • Save Shogun89/b53173deab0f45adea973c90a15c8498 to your computer and use it in GitHub Desktop.
Save Shogun89/b53173deab0f45adea973c90a15c8498 to your computer and use it in GitHub Desktop.
from math import sqrt
def get_triangle_area(a,b,c):
''' Given triangle side lengths a,b,c returns the area of the triangle '''
assert a > 0 and b > 0 and c > 0, "Side lengths must be positive"
s = (a+b+c)/2
area = sqrt(s*(s-a)*(s-b)*(s-c))
return area
a = 3
b = 4
c = 5
print(get_triangle_area(a,b,c))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment