Python: To calculate the third angle of a triangle if two angles are given

Program 11. Write a python Program to input two angles of a triangle and find third angle of the triangle. How to find all angles of a triangle if two angles are given by user using python programming. Python program to calculate the third angle of a triangle if two angles are given.

For Example
Input
Enter first angle: 60 degree
Enter second angle: 80 degree
Output
Third angle = 40 degree
Properties of triangle
We know that sum of all angles of a triangle is 180° .
a+b+c=180 degree
Hence, by applying basic mathematics we can easily deduct a formula for finding
the third angle. The formula for third angle is given by –
c = 180 – ( a+ b )
Logic to find third angle of a triangle
Basic step by step descriptive logic to find third angle of a triangle –
1. Read two angles of the triangle from user and store it in some variable say a and b.
2. Now, apply the formula for finding third angle. Which is c = 180 – (a + b).
3. Print the value of c. Which is the required third angle of the triangle.

#Let us now code the solution
print(“\n\t\t\t https://learnpythonforcbse.wordpress.com/”)
#Input two angles of the triangle
print(“Enter two angles of triangle: “)
a = float(input())
b = float(input())
#Calculate the third angle

c = 180 – (a + b);

#Print the value of third angle
print(“Third angle of the triangle = “, c)
print(“\n\t\t\t https://learnpythonforcbse.wordpress.com/”)

OUTPUT:

prog11.png

Leave a comment