Python Forum
How do I get the tangent of a degree - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How do I get the tangent of a degree (/thread-21994.html)



How do I get the tangent of a degree - SheeppOSU - Oct-24-2019

I was trying to get the tangent of a degree, but math.tan returns the radian. How do I get the tangent of a degree? I hope I worded that right.

I figured it out, I just need to use math.radians on the number I was trying to find the tangent of according to a stackoverflow thread I found here - https://stackoverflow.com/questions/9875964/python-converting-radians-to-degrees


RE: How do I get the tangent of a degree - ichabod801 - Oct-24-2019

The math module has two functions for converting between radians and degrees, so to get the tangent in degrees of a measurement in degrees, you would use math.degrees(math.tan(math.radians(theta)), where theta is the angle you are getting the tangent for.


RE: How do I get the tangent of a degree - scidam - Oct-24-2019

(Oct-24-2019, 01:33 AM)SheeppOSU Wrote: I was trying to get the tangent of a degree, but math.tan returns the radian


math.tan(x) doesn't return radians (it returns value of tangent for specific angle -- x which is (expected to be) given in radians). math.atan is inverse function to math.tan, therefore, it returns radians. So, math.tan(x) requires x to be in radians. If you want to calculate, e.g. tan(60 degrees), you need to convert 60 degrees to radians: tan(60 degrees) = math.tan(math.radians(60)). Note, that conversion between radians and degrees is very simple: math.radians(deg) = deg * math.pi / 180.0.


RE: How do I get the tangent of a degree - ichabod801 - Oct-24-2019

Duh, listen to scidam.