Please someone help me e to solve the problem in my code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Please someone help me e to solve the problem in my code

from math import sin from math import cos from math import tan def t(x): return sin(x) def t1(x): return cos(x) def t2(x): return ten(x) def t3(x): return 1/(tan(x)) def t4(x): return 1/(cos(x)) def t5(x): return 1/(sin(x)) s=input("which trigonometry function you want to use:") a=input("measure of corresponding angle:") if s==sin: print(t(a)) The fact is the code overall work upto take inputs but after that it should print the result but it does not print any result

5th Apr 2019, 3:34 PM
GANESH KHADANGA
GANESH KHADANGA - avatar
3 Answers
+ 4
hi ganesh, please change: (1): a=input("measure of corresponding angle:") to a=int(input("measure of corresponding angle:")) sin function expects a numerical input, so you have to to make a conversion to int. (2): if s == sin: to if s == 'sin': The input in var s is a string, so you need to compare it with 'sin'. These changes will make the code run for sin calculation. Please make s clear remark, that running the code in SoloLearn Playground needs to make input in input windows in 2 lines: sin 45
5th Apr 2019, 4:07 PM
Lothar
Lothar - avatar
+ 3
a = float(input()) if s=='sin': Also, note that python uses radians instead of degrees. To get the sin of a 30 deg angle, you need to convert the angle to radians first: from math import sin, radians print(sin(radians(30))) # 0.5
5th Apr 2019, 3:49 PM
Anna
Anna - avatar
+ 1
Thanks for your valuable suggestions which make my code get work properly
5th Apr 2019, 4:14 PM
GANESH KHADANGA
GANESH KHADANGA - avatar