Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading