# Python Program to Calculate Perimeter of Triangle

## Calculate Perimeter of Triangle in Python

To calculate perimeter of a triangle in python, you have to ask from user to enter length of first, second, and third side of the triangle to calculate perimeter of that triangle as shown in the program given below.

## Python Programming Code to Calculate Perimeter of Triangle

Following python program ask from user to enter the length of all the three sides of triangle to find the perimeter of that triangle:

```# Python Program - Calculate Perimeter of Triangle

print("Enter 'x' for exit.");
len1 = input("Enter length of first side: ");
if len1 == 'x':
exit();
else:
len2 = input("Enter length of second side: ");
len3 = input("Enter length of third side: ");
length1 = int(len1);
length2 = int(len2);
length3 = int(len3);
perimeter = length1 + length2 + length3;
print("\nPerimeter of Triangle =", perimeter);
```

Here is the sample run of the above Python program to show how to calculate perimeter of a triangle: Perimeter of triangle can be calculated as summing up all the three sides, that is length_of_first_side + length_of_second_side + length_of_third_side.

Above is the initial output, enter length of all the three sides and then press enter key to find out the perimeter of the triangle as shown here in below sample output: As you can see from the above output, summing up all the three side length of the triangle that is length+breadth+height say 10+20+30 is equal to 60 as perimeter of this triangle.

Here is the same program on python shell:< Tools
Calculator