{"id":24260,"date":"2021-10-14T09:19:12","date_gmt":"2021-10-14T03:49:12","guid":{"rendered":"https:\/\/python-programs.com\/?p=24260"},"modified":"2021-11-05T21:02:55","modified_gmt":"2021-11-05T15:32:55","slug":"python-program-for-acos-function","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-acos-function\/","title":{"rendered":"Python Program for acos() Function"},"content":{"rendered":"
In the previous article, we have discussed Python Program for log() Function<\/a> The math.acos() method returns a number’s arc cosine value. Python acos, also known as Arc cosine, is the inverse of a cosine.<\/p>\n Note:<\/strong> It should be noted that the parameter passed to math.acos() must be between -1 and 1.<\/p>\n Tip:<\/strong> The value of PI will be returned by math.acos(-1).<\/p>\n Syntax:<\/strong><\/p>\n Parameters:<\/strong><\/p>\n x: <\/strong>This is required. It is a number between -1 and 1. If x is not a number, a TypeError is returned.<\/p>\n Return Value:<\/strong><\/p>\n Returns a float value which represents a number’s arc cosine.<\/p>\n 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 log() Function acos() Function in Python: The math.acos() method returns a number’s arc cosine value. Python acos, also known as Arc cosine, is the inverse of a cosine. Note: It should be noted that the parameter passed to math.acos() must be between -1 and 1. …<\/p>\n
\nacos() Function in Python:<\/strong><\/p>\nmath.acos(x)<\/pre>\n
\n
Given first number = 0.5\r\nGiven second number = 1<\/pre>\n
The result after applying acos() function on above given first number 0.5 = 1.0471975511965979\r\nThe result after applying acos() function on above given second number 1 = 0.0<\/pre>\n
Given first number = 0.3\r\nGiven second number = -0.2<\/pre>\n
The result after applying acos() function on above given first number 0.3 = 1.2661036727794992\r\nThe result after applying acos() function on above given second number -0.2 = 1.7721542475852274<\/pre>\n
Program for acos() 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.5, 0.2, 1, 0.8]\r\n# Give the first number as static input and store it in another variable.\r\ngvn_numb1 = 0.5\r\n# Apply math.acos() function to the given first number to get arc cosine value\r\n# (inverse of cosine) of a given number.\r\n# Store it in another variable.\r\nfnl_rslt = math.acos(gvn_numb1)\r\nprint(\"The result after applying acos() 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 acos() function on above given second number\",\r\n gvn_numb2, \" = \", math.acos(gvn_numb2))\r\n# Apply math.acos() function to the given list element and print it.\r\nprint(\r\n \"The result after applying acos() function on given list element gvnlst[1] = \", math.acos(gvn_lst[1]))\r\n<\/pre>\n
The result after applying acos() function on above given first number 0.5 = 1.0471975511965979\r\nThe result after applying acos() function on above given second number 1 = 0.0\r\nThe result after applying acos() function on given list element gvnlst[1] = 1.369438406004566<\/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.acos() function to the given first number to get arc cosine value\r\n# (inverse of cosine) of a given number.\r\n# Store it in another variable.\r\nfnl_rslt = math.acos(gvn_numb1)\r\nprint(\"The result after applying acos() 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 acos() function on above given second number\",\r\n gvn_numb2, \" = \", math.acos(gvn_numb2))\r\n# Apply math.acos() function to the given list element and print it.\r\nprint(\r\n \"The result after applying acos() function on given list element gvnlst[2] = \", math.acos(gvn_lst[2]))\r\n\r\n\r\n<\/pre>\n
Enter some random List Elements separated by spaces = 1 2 0.3 0.5\r\nEnter some random number = 0.38\r\nThe result after applying acos() function on above given first number 0.38 = 1.181000030320636\r\nEnter some random number = 0.6\r\nThe result after applying acos() function on above given second number 0.6 = 0.9272952180016123\r\nThe result after applying acos() function on given list element gvnlst[2] = 1.2661036727794992<\/pre>\n
\n