This Python program reads two triangle sides B and C and the angle α between them.
It calculates the third side A using the Law of Cosines:
A² = B² + C² - 2 × B × C × cos(α)
The angle must be converted to radians before applying cos.
import math
def third_side(B: float, C: float, alpha_deg: float) -> float:
alpha_rad = math.radians(alpha_deg)
A_squared = B**2 + C**2 - 2 * B * C * math.cos(alpha_rad)
return math.sqrt(A_squared)
# Read inputs from user
B = float(input("Enter side B: "))
C = float(input("Enter side C: "))
alpha = float(input("Enter angle between B and C (in degrees): "))
A = third_side(B, C, alpha)
print(f"Length of third side A is: {A:.2f}")
Length of third side A is: 6.24