Write a program to calculate area of triangle, taking three sides from user.

 Q. Write a program to calculate area of triangle, taking three sides from user.

Code:-

a = float(input("Enter first side:"))
b = float(input("Enter second side:"))
c = float(input("Enter third side:"))

if a<0 or b<0 or c<0:
  print("The triangle is not possible.")
elif a+b>c or b+c>a or c+a>b :
  s = (a + b + c)/2
  area = (s*(s-a)*(s-b)*(s-c))**0.5
  print('The area of the triangle is',area)
else:
  print("The triangle is not possible.")


 

Output:-







Comments