trig_solver.py

Created by 07-cartoon-sinus

Created on March 09, 2025

732 Bytes


from math import sin, cos, tan, radians

print("Solve for: ")
print("1. Opposite side (sin)")
print("2. Adjacent side (cos)")
print("3. Tangent (tan)")

choice = int(input("Enter choice: "))

angle = float(input("Enter angle in degrees: "))
hypotenuse = float(input("Enter hypotenuse: "))

if choice == 1:
    result = hypotenuse * sin(radians(angle))
    print("Opposite side is:", round(result, 2))
elif choice == 2:
    result = hypotenuse * cos(radians(angle))
    print("Adjacent side is:", round(result, 2))
elif choice == 3:
    opposite = float(input("Enter opposite side: "))
    result = opposite / tan(radians(angle))
    print("Adjacent side is:", round(result, 2))
else:
    print("Invalid choice.")

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.