Home > Blockchain >  How to find tan^2(30) in python?
How to find tan^2(30) in python?

Time:08-28

I wanted to find tan^2(x) in Python and it is different from tan(x)^2 which can be found using the following:

(math.tan(30))**2

CodePudding user response:

Your Python expression is the correct way to calculate tan2 30, but that is the squared tangent of 30 radians.

You probably want the squared tangent of 30 degrees, so you need to convert degrees to radians. You can do the conversion yourself:

>>> (math.tan(30 * math.pi / 180))**2
0.33333333333333315

Or you can use math.radians:

>>> math.tan(math.radians(30))**2
0.33333333333333315
  • Related