Monday, July 27, 2020

Write a Program to find the area of a triangle in Python.

Area of a triangle in Python.


x = float(input('Enter first side :: '))  
y = float(input('Enter second side :: '))  
z = float(input('Enter third side :: '))  
  
# Calculate the semi-perimeter  ..........

m = (x + y + z) / 2  
  
# Calculate the area  ..........

area = (m*(m-x)*(m-y)*(m-z)) ** 0.5  
print('The area of the triangle is : %0.2f' %area)   


OUTPUT

Enter first side :: 5
     Enter second side :: 4
Enter third side :: 7

The area of the triangle is :9.80



No comments:

Post a Comment

Please do not any spam link in Comment Box