{"id":24304,"date":"2021-10-14T09:18:24","date_gmt":"2021-10-14T03:48:24","guid":{"rendered":"https:\/\/python-programs.com\/?p=24304"},"modified":"2021-11-05T21:05:32","modified_gmt":"2021-11-05T15:35:32","slug":"python-program-for-atan-function","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-atan-function\/","title":{"rendered":"Python Program for atan() Function"},"content":{"rendered":"
In the previous article, we have discussed Python Program for asin() Function<\/a> The arc tangent of a number (x) is returned as a numeric value between -PI\/2 and PI\/2 radians by the math.atan() method.<\/p>\n Arc tangent is also defined as an inverse tangent function of x, where x is the value to be calculated for the arc tangent.<\/p>\n Syntax:<\/strong><\/p>\n Parameters:<\/strong><\/p>\n x: <\/strong>This is Required. It is a number that is either positive or negative. If x is not a number, TypeError is returned.<\/p>\n Return Value:<\/strong><\/p>\n It returns a float value ranging from -PI\/2 to PI\/2 representing a number’s arc tangent.<\/p>\n The Arc Tangent value is returned if the number argument is positive or negative. Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Know all about Mathematical Functions in Python by going through our Python Mathematical Methods Examples<\/a> well explained step by step.<\/p>\n In the previous article, we have discussed Python Program for asin() Function atan() Function in Python: The arc tangent of a number (x) is returned as a numeric value between -PI\/2 and PI\/2 radians by the math.atan() method. Arc tangent is also defined as an inverse tangent function of x, where x is the value …<\/p>\n
\natan() Function in Python:<\/strong><\/p>\nmath.atan(x)<\/pre>\n
\nThe atan() function throws a TypeError if the number argument is not a number.<\/p>\nGiven first number = 0.7\r\nGiven second number = 1<\/pre>\n
The result after applying atan() function on above given first number 0.7 = 0.6107259643892086\r\nThe result after applying atan() function on above given second number 1 = 0.7853981633974483<\/pre>\n
Given first number = -1\r\nGiven second number = 0.3<\/pre>\n
The result after applying atan() function on above given first number -1 = -0.7853981633974483\r\nThe result after applying atan() function on above given second number 0.3 = 0.2914567944778671<\/pre>\n
Program for atan() Function in Python<\/h2>\n
\n
Method #1: Using Built-in Functions (Static Input)<\/h3>\n
\n
# Import math module using the import keyword.\r\nimport math\r\n# Give the list as static input and store it in a variable.\r\ngvn_lst = [0.6, -0.3, 1, 0.8]\r\n# Give the first number as static input and store it in another variable.\r\ngvn_numb1 = 0.7\r\n# Apply math.atan() function to the given first number to get arc tangent value\r\n# (inverse of tangent) of a given number.\r\n# Store it in another variable.\r\nfnl_rslt = math.atan(gvn_numb1)\r\nprint(\"The result after applying atan() function on above given first number\",\r\n gvn_numb1, \" = \", fnl_rslt)\r\n# similarly do the same for the other number.\r\ngvn_numb2 = 1\r\nprint(\"The result after applying atan() function on above given second number\",\r\n gvn_numb2, \" = \", math.atan(gvn_numb2))\r\n# Apply math.atan() function to the given list element and print it.\r\nprint(\r\n \"The result after applying atan() function on given list element gvnlst[1] = \", math.atan(gvn_lst[1]))\r\n<\/pre>\n
The result after applying atan() function on above given first number 0.7 = 0.6107259643892086\r\nThe result after applying atan() function on above given second number 1 = 0.7853981633974483\r\nThe result after applying atan() function on given list element gvnlst[1] = -0.2914567944778671<\/pre>\n
Method #2: Using Built-in Functions (User Input)<\/h3>\n
\n
# Import math module using the import keyword.\r\nimport math\r\n# Give the list as user input using list(),map(),input(),and split() functions.\r\n# Store it in a variable.\r\ngvn_lst = list(map(float, input(\r\n 'Enter some random List Elements separated by spaces = ').split()))\r\n# Give the first number as user input using the float(input()) function\r\n# and store it in a variable.\r\ngvn_numb1 = float(input(\"Enter some random number = \"))\r\n# Apply math.atan() function to the given first number to get arc tangent value\r\n# (inverse of tangent) of a given number.\r\n# Store it in another variable.\r\nfnl_rslt = math.atan(gvn_numb1)\r\nprint(\"The result after applying atan() function on above given first number\",\r\n gvn_numb1, \" = \", fnl_rslt)\r\n# similarly do the same for the other number.\r\ngvn_numb2 = float(input(\"Enter some random number = \"))\r\nprint(\"The result after applying atan() function on above given second number\",\r\n gvn_numb2, \" = \", math.atan(gvn_numb2))\r\n# Apply math.atan() function to the given list element and print it.\r\nprint(\r\n \"The result after applying atan() function on given list element gvnlst[2] = \", math.atan(gvn_lst[2]))\r\n\r\n<\/pre>\n
Enter some random List Elements separated by spaces = 0 2 0.9 1 -3\r\nEnter some random number = -1\r\nThe result after applying atan() function on above given first number -1.0 = -0.7853981633974483\r\nEnter some random number = 0.3\r\nThe result after applying atan() function on above given second number 0.3 = 0.2914567944778671\r\nThe result after applying atan() function on given list element gvnlst[2] = 0.7328151017865066<\/pre>\n
\n