0

Trigenometry In Python

I made this calculator to calculate trigenometric values, but it appears to be getting it wrong according to my scientific calculator. This is the python calculator that isn't working: while True: print('type "sine1" to find the value of the Opposite') print('type "sine2" to find the value of the Hypotenuse') print('type "cosine1" to find the value of the Adjacent') print('type "cosine2" to find the value of the Hypotenuse') print('type "tangent1" to find the value of the Opposite') print('type "tangent2" to find the value of the Adjacent') user_input = input(": ") from math import sin, cos, tan if user_input == 'sine1': degrees = float(input('Enter the degrees: ')) hypotenuse = float(input('Enter the value of the hypotenuse: ')) result = str(hypotenuse * sin(degrees)) print('The answer is ' + result) print(input('Press enter to quit: ')) break elif user_input == 'sine2': degrees = float(input('Enter the degrees: ')) opposite = float(input('Enter the value of the opposite: ')) result = str(opposite / sin(degrees)) print('The answer is ' + result) print(input('Press enter to quit: ')) break elif user_input == 'cosine1': degrees = float(input('Enter the degrees: ')) hypotenuse = float(input('Enter the value of the hypotenuse: ')) result = str(hypotenuse * cos(degrees)) print('The answer is ' + result) print(input('Press enter to quit: ')) break elif user_input == 'cosine2': degrees = float(input('Enter the degrees: ')) adjacent = float(input('Enter the value of the adjacent: ')) result = str(adjacent / cos(degrees)) print('The answer is ' + result) print(input('Press enter to quit: ')) break elif user_input == 'tangent1 ': degrees = float(input('Enter the degrees: '))

6th Jun 2018, 2:22 AM
Lachlan Taylor
1 Resposta
+ 4
use, from math import radians sin(radians(degrees)) cos(radians(degrees)) #since sin ,cos and tan,takes values in radians may be this should you need
6th Jun 2018, 2:33 AM
Venkat
Venkat - avatar