{"id":1003475,"date":"2024-12-27T10:17:35","date_gmt":"2024-12-27T02:17:35","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1003475.html"},"modified":"2024-12-27T10:17:37","modified_gmt":"2024-12-27T02:17:37","slug":"python%e5%a6%82%e4%bd%95%e8%be%93%e5%85%a5%e5%bc%a7%e5%ba%a6%e8%a7%92","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1003475.html","title":{"rendered":"python\u5982\u4f55\u8f93\u5165\u5f27\u5ea6\u89d2"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25080820\/fd78addc-9b9a-468e-907b-61b7887bc951.webp\" alt=\"python\u5982\u4f55\u8f93\u5165\u5f27\u5ea6\u89d2\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u8f93\u5165\u5f27\u5ea6\u89d2\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\uff1a\u4f7f\u7528\u5185\u7f6e\u6570\u5b66\u5e93\u4e2d\u7684\u5f27\u5ea6\u51fd\u6570\u3001\u76f4\u63a5\u8f93\u5165\u5f27\u5ea6\u503c\u3001\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\u3002<\/strong> \u5176\u4e2d\uff0c\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u5229\u7528Python\u7684<code>math<\/code>\u5e93\uff0c\u901a\u8fc7\u51fd\u6570<code>math.radians()<\/code>\u5c06\u89d2\u5ea6\u503c\u8f6c\u6362\u4e3a\u5f27\u5ea6\u3002<code>math.radians()<\/code>\u662f\u4e00\u4e2a\u975e\u5e38\u65b9\u4fbf\u7684\u51fd\u6570\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u8f7b\u677e\u5730\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\uff0c\u4ece\u800c\u5728\u9700\u8981\u8fdb\u884c\u4e09\u89d2\u51fd\u6570\u8ba1\u7b97\u65f6\u4f7f\u7528\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u89e3\u91ca\u5982\u4f55\u5728Python\u4e2d\u5904\u7406\u5f27\u5ea6\u89d2\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5229\u7528MATH\u5e93\u4e2d\u7684\u5f27\u5ea6\u51fd\u6570<\/p>\n<\/p>\n<p><p>Python\u7684<code>math<\/code>\u5e93\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u6570\u5b66\u51fd\u6570\uff0c\u5176\u4e2d\u5305\u62ec\u7528\u4e8e\u89d2\u5ea6\u4e0e\u5f27\u5ea6\u8f6c\u6362\u7684<code>math.radians()<\/code>\u548c<code>math.degrees()<\/code>\u51fd\u6570\u3002<code>math.radians()<\/code>\u51fd\u6570\u7528\u4e8e\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\uff0c\u800c<code>math.degrees()<\/code>\u7528\u4e8e\u5c06\u5f27\u5ea6\u8f6c\u6362\u4e3a\u89d2\u5ea6\u3002\u8fd9\u4e9b\u51fd\u6570\u7684\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6<\/strong><\/h2>\n<p>angle_in_degrees = 90<\/p>\n<p>angle_in_radians = math.radians(angle_in_degrees)<\/p>\n<p>print(angle_in_radians)  # \u8f93\u51fa\uff1a1.5707963267948966<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>math.radians()<\/code>\u51fd\u6570\u5c0690\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\u3002\u8be5\u51fd\u6570\u8fd4\u56de\u7684\u7ed3\u679c\u662f\u4ee5\u5f27\u5ea6\u8868\u793a\u7684\u89d2\u5ea6\uff0c\u8fd9\u975e\u5e38\u6709\u5229\u4e8e\u540e\u7eed\u7684\u4e09\u89d2\u51fd\u6570\u8ba1\u7b97\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u76f4\u63a5\u8f93\u5165\u5f27\u5ea6\u503c<\/p>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u5df2\u7ecf\u77e5\u9053\u8981\u4f7f\u7528\u7684\u5f27\u5ea6\u503c\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u4ee3\u7801\u4e2d\u8f93\u5165\u5f27\u5ea6\u503c\u3002\u8fd9\u662f\u4e00\u79cd\u7b80\u5355\u800c\u76f4\u63a5\u7684\u65b9\u6cd5\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u5e38\u89c1\u7684\u5f27\u5ea6\u503c\u65f6\uff0c\u4f8b\u5982\u03c0\uff08\u03c0\u5f27\u5ea6\u7b49\u4e8e180\u5ea6\uff09\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u76f4\u63a5\u4f7f\u7528\u5f27\u5ea6\u503c<\/strong><\/h2>\n<p>angle_in_radians = math.pi \/ 2<\/p>\n<p>print(angle_in_radians)  # \u8f93\u51fa\uff1a1.5707963267948966<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u76f4\u63a5\u4f7f\u7528<code>math.pi<\/code>\u6765\u8868\u793a\u03c0\uff0c<code>math.pi \/ 2<\/code>\u8868\u793a\u03c0\/2\u5f27\u5ea6\uff0c\u4e5f\u5c31\u662f90\u5ea6\u3002\u8fd9\u79cd\u65b9\u6cd5\u975e\u5e38\u76f4\u63a5\uff0c\u9002\u7528\u4e8e\u5df2\u77e5\u7684\u5f27\u5ea6\u503c\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6<\/p>\n<\/p>\n<p><p>\u5f53\u9700\u8981\u5728\u4ee3\u7801\u4e2d\u5904\u7406\u4ee5\u5ea6\u4e3a\u5355\u4f4d\u7684\u89d2\u5ea6\u65f6\uff0c\u901a\u5e38\u9700\u8981\u5c06\u8fd9\u4e9b\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\uff0c\u4ee5\u4fbf\u4e0ePython\u7684\u4e09\u89d2\u51fd\u6570\u4e00\u8d77\u4f7f\u7528\u3002Python\u63d0\u4f9b\u7684<code>math.radians()<\/code>\u51fd\u6570\u5c31\u662f\u4e3a\u4e86\u8fd9\u79cd\u9700\u6c42\u800c\u8bbe\u8ba1\u7684\u3002\u901a\u8fc7\u8fd9\u4e2a\u51fd\u6570\uff0c\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u5c06\u4efb\u610f\u5ea6\u6570\u7684\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u5c06\u591a\u4e2a\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6<\/strong><\/h2>\n<p>angles_in_degrees = [0, 30, 45, 60, 90, 180, 270, 360]<\/p>\n<p>angles_in_radians = [math.radians(deg) for deg in angles_in_degrees]<\/p>\n<p>print(angles_in_radians)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u4e00\u7ec4\u5e38\u89c1\u7684\u89d2\u5ea6\u503c\u8f6c\u6362\u4e3a\u5f27\u5ea6\u3002\u901a\u8fc7\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u5feb\u901f\u5730\u5c06\u591a\u4e2a\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\uff0c\u8fd9\u5728\u5904\u7406\u9700\u8981\u5927\u91cf\u89d2\u5ea6\u8f6c\u6362\u7684\u573a\u666f\u4e2d\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u4f7f\u7528\u5f27\u5ea6\u8fdb\u884c\u4e09\u89d2\u51fd\u6570\u8ba1\u7b97<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u6240\u6709\u7684\u4e09\u89d2\u51fd\u6570\u90fd\u9700\u8981\u4ee5\u5f27\u5ea6\u4f5c\u4e3a\u8f93\u5165\u53c2\u6570\u3002\u56e0\u6b64\uff0c\u7406\u89e3\u5982\u4f55\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\u662f\u4f7f\u7528\u8fd9\u4e9b\u51fd\u6570\u7684\u524d\u63d0\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u4e09\u89d2\u51fd\u6570\u53ca\u5176\u4f7f\u7528\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong><code>math.sin()<\/code><\/strong>\u548c<strong><code>math.cos()<\/code><\/strong>\uff1a\u7528\u4e8e\u8ba1\u7b97\u6b63\u5f26\u548c\u4f59\u5f26\u503c\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u8ba1\u7b97\u6b63\u5f26\u548c\u4f59\u5f26\u503c<\/strong><\/h2>\n<p>angle_in_degrees = 45<\/p>\n<p>angle_in_radians = math.radians(angle_in_degrees)<\/p>\n<p>sine_value = math.sin(angle_in_radians)<\/p>\n<p>cosine_value = math.cos(angle_in_radians)<\/p>\n<p>print(f&quot;Sine of {angle_in_degrees} degrees: {sine_value}&quot;)<\/p>\n<p>print(f&quot;Cosine of {angle_in_degrees} degrees: {cosine_value}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5c0645\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\uff0c\u7136\u540e\u4f7f\u7528<code>math.sin()<\/code>\u548c<code>math.cos()<\/code>\u51fd\u6570\u8ba1\u7b97\u5176\u6b63\u5f26\u548c\u4f59\u5f26\u503c\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li><strong><code>math.tan()<\/code><\/strong>\uff1a\u7528\u4e8e\u8ba1\u7b97\u6b63\u5207\u503c\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u8ba1\u7b97\u6b63\u5207\u503c<\/strong><\/h2>\n<p>angle_in_degrees = 60<\/p>\n<p>angle_in_radians = math.radians(angle_in_degrees)<\/p>\n<p>tangent_value = math.tan(angle_in_radians)<\/p>\n<p>print(f&quot;Tangent of {angle_in_degrees} degrees: {tangent_value}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6b63\u5207\u51fd\u6570\u7684\u7528\u6cd5\u4e0e\u6b63\u5f26\u548c\u4f59\u5f26\u51fd\u6570\u7c7b\u4f3c\uff0c\u53ea\u9700\u6ce8\u610f\u8f93\u5165\u7684\u89d2\u5ea6\u9700\u8981\u8f6c\u6362\u4e3a\u5f27\u5ea6\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u5c06\u5f27\u5ea6\u8f6c\u6362\u4e3a\u89d2\u5ea6<\/p>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u5c06\u8ba1\u7b97\u7ed3\u679c\u4ece\u5f27\u5ea6\u8f6c\u6362\u56de\u89d2\u5ea6\u3002Python\u7684<code>math.degrees()<\/code>\u51fd\u6570\u53ef\u4ee5\u5b9e\u73b0\u8fd9\u4e00\u70b9\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u5c06\u5f27\u5ea6\u8f6c\u6362\u4e3a\u89d2\u5ea6<\/strong><\/h2>\n<p>angle_in_radians = math.pi \/ 4<\/p>\n<p>angle_in_degrees = math.degrees(angle_in_radians)<\/p>\n<p>print(f&quot;{angle_in_radians} radians is equal to {angle_in_degrees} degrees&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06\u03c0\/4\u5f27\u5ea6\u8f6c\u6362\u56de\u89d2\u5ea6\uff0c\u7ed3\u679c\u4e3a45\u5ea6\u3002\u8fd9\u79cd\u8f6c\u6362\u5bf9\u4e8e\u9700\u8981\u4ee5\u5ea6\u4e3a\u5355\u4f4d\u8fdb\u884c\u8f93\u51fa\u6216\u62a5\u544a\u7684\u5e94\u7528\u7a0b\u5e8f\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<p><p>\u516d\u3001\u5b9e\u9645\u5e94\u7528\u6848\u4f8b<\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u8df5\u4e2d\uff0c\u5904\u7406\u5f27\u5ea6\u548c\u89d2\u5ea6\u7684\u8f6c\u6362\u901a\u5e38\u7528\u4e8e\u9700\u8981\u7cbe\u786e\u8ba1\u7b97\u7684\u9886\u57df\uff0c\u5982\u8ba1\u7b97\u673a\u56fe\u5f62\u5b66\u3001\u5de5\u7a0b\u5b66\u548c\u7269\u7406\u5b66\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528\u5f27\u5ea6\u548c\u89d2\u5ea6\u8f6c\u6362\u7684\u5b9e\u9645\u5e94\u7528\u6848\u4f8b\uff1a<\/p>\n<\/p>\n<p><p>\u5047\u8bbe\u6211\u4eec\u6b63\u5728\u5f00\u53d1\u4e00\u4e2a\u7b80\u5355\u7684\u6a21\u62df\u5668\uff0c\u7528\u4e8e\u8ba1\u7b97\u629b\u7269\u7ebf\u8fd0\u52a8\u4e2d\u7269\u4f53\u7684\u8f68\u8ff9\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4e86\u89e3\u521d\u59cb\u53d1\u5c04\u89d2\u5ea6\u4ee5\u53ca\u5176\u4e0e\u6c34\u5e73\u7ebf\u7684\u5939\u89d2\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5f27\u5ea6\u89d2\u6765\u8ba1\u7b97\u7269\u4f53\u5728\u7ed9\u5b9a\u65f6\u95f4\u70b9\u7684\u6c34\u5e73\u548c\u5782\u76f4\u4f4d\u7f6e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>def calculate_trajectory(initial_velocity, launch_angle_degrees, time):<\/p>\n<p>    # \u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6<\/p>\n<p>    launch_angle_radians = math.radians(launch_angle_degrees)<\/p>\n<p>    # \u8ba1\u7b97\u6c34\u5e73\u548c\u5782\u76f4\u5206\u91cf<\/p>\n<p>    horizontal_velocity = initial_velocity * math.cos(launch_angle_radians)<\/p>\n<p>    vertical_velocity = initial_velocity * math.sin(launch_angle_radians)<\/p>\n<p>    # \u8ba1\u7b97\u4f4d\u7f6e<\/p>\n<p>    g = 9.81  # \u91cd\u529b\u52a0\u901f\u5ea6<\/p>\n<p>    x = horizontal_velocity * time<\/p>\n<p>    y = vertical_velocity * time - 0.5 * g * time2<\/p>\n<p>    return x, y<\/p>\n<h2><strong>\u793a\u4f8b\uff1a\u521d\u901f\u5ea6\u4e3a20 m\/s\uff0c\u53d1\u5c04\u89d2\u5ea6\u4e3a30\u5ea6\uff0c\u8ba1\u7b972\u79d2\u540e\u7684\u4f4d\u7f6e<\/strong><\/h2>\n<p>initial_velocity = 20  # m\/s<\/p>\n<p>launch_angle_degrees = 30  # degrees<\/p>\n<p>time = 2  # seconds<\/p>\n<p>x, y = calculate_trajectory(initial_velocity, launch_angle_degrees, time)<\/p>\n<p>print(f&quot;Position at {time} seconds: x = {x}, y = {y}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u6848\u4f8b\u4e2d\uff0c\u6211\u4eec\u8ba1\u7b97\u4e86\u7269\u4f53\u5728\u53d1\u5c04\u540e\u76842\u79d2\u949f\u5185\u7684\u4f4d\u7f6e\u3002\u901a\u8fc7\u5c06\u53d1\u5c04\u89d2\u5ea6\u4ece\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\uff0c\u6211\u4eec\u53ef\u4ee5\u51c6\u786e\u5730\u8ba1\u7b97\u6c34\u5e73\u548c\u5782\u76f4\u901f\u5ea6\u5206\u91cf\uff0c\u7136\u540e\u4f7f\u7528\u8fd9\u4e9b\u4fe1\u606f\u6765\u786e\u5b9a\u7269\u4f53\u5728\u6307\u5b9a\u65f6\u95f4\u70b9\u7684\u5750\u6807\u4f4d\u7f6e\u3002<\/p>\n<\/p>\n<p><p>\u603b\u7ed3\uff1a<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\u5904\u7406\u5f27\u5ea6\u89d2\u7684\u5173\u952e\u5728\u4e8e\u6b63\u786e\u4f7f\u7528<code>math<\/code>\u5e93\u4e2d\u7684\u51fd\u6570\uff0c\u5982<code>math.radians()<\/code>\u548c<code>math.degrees()<\/code>\u3002\u7406\u89e3\u8fd9\u4e9b\u51fd\u6570\u7684\u7528\u6cd5\uff0c\u4ee5\u53ca\u5982\u4f55\u5728\u4e09\u89d2\u51fd\u6570\u8ba1\u7b97\u4e2d\u5e94\u7528\u5f27\u5ea6\uff0c\u662f\u8fdb\u884c\u6709\u6548\u6570\u5b66\u8ba1\u7b97\u7684\u57fa\u7840\u3002\u5728\u5e94\u7528\u4e2d\uff0c\u7279\u522b\u662f\u5728\u6d89\u53ca\u7269\u7406\u6a21\u62df\u548c\u5de5\u7a0b\u8ba1\u7b97\u7684\u9886\u57df\uff0c\u719f\u7ec3\u638c\u63e1\u89d2\u5ea6\u4e0e\u5f27\u5ea6\u4e4b\u95f4\u7684\u8f6c\u6362\u5c06\u6781\u5927\u5730\u63d0\u9ad8\u8ba1\u7b97\u7684\u51c6\u786e\u6027\u548c\u6548\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>math<\/code>\u6a21\u5757\u4e2d\u7684<code>radians()<\/code>\u51fd\u6570\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u6709\u4e00\u4e2a\u89d2\u5ea6\u4e3a30\u5ea6\uff0c\u53ef\u4ee5\u901a\u8fc7<code>math.radians(30)<\/code>\u5c06\u5176\u8f6c\u6362\u4e3a\u5f27\u5ea6\u3002\u8fd9\u6837\u505a\u53ef\u4ee5\u786e\u4fdd\u5728\u8fdb\u884c\u4e09\u89d2\u51fd\u6570\u8ba1\u7b97\u65f6\u4f7f\u7528\u6b63\u786e\u7684\u5355\u4f4d\u3002<\/p>\n<p><strong>Python\u4e2d\u5982\u4f55\u8bfb\u53d6\u7528\u6237\u8f93\u5165\u7684\u5f27\u5ea6\u503c\uff1f<\/strong><br \/>\u4f7f\u7528<code>input()<\/code>\u51fd\u6570\u53ef\u4ee5\u8bfb\u53d6\u7528\u6237\u7684\u8f93\u5165\u3002\u8bfb\u53d6\u5230\u7684\u503c\u901a\u5e38\u662f\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u53ef\u4ee5\u4f7f\u7528<code>float()<\/code>\u51fd\u6570\u5c06\u5176\u8f6c\u6362\u4e3a\u6d6e\u70b9\u6570\uff0c\u4ee5\u4fbf\u8fdb\u884c\u6570\u5b66\u8ba1\u7b97\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a  <\/p>\n<pre><code class=\"language-python\">radian = float(input(&quot;\u8bf7\u8f93\u5165\u5f27\u5ea6\u503c\uff1a&quot;))\n<\/code><\/pre>\n<p><strong>\u5728Python\u4e2d\uff0c\u5982\u4f55\u4f7f\u7528\u5f27\u5ea6\u8fdb\u884c\u4e09\u89d2\u51fd\u6570\u8ba1\u7b97\uff1f<\/strong><br \/>Python\u7684<code>math<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u591a\u79cd\u4e09\u89d2\u51fd\u6570\uff0c\u4f8b\u5982<code>sin()<\/code>\u3001<code>cos()<\/code>\u548c<code>tan()<\/code>\u3002\u8fd9\u4e9b\u51fd\u6570\u63a5\u53d7\u5f27\u5ea6\u4f5c\u4e3a\u53c2\u6570\u3002\u786e\u4fdd\u5728\u8c03\u7528\u8fd9\u4e9b\u51fd\u6570\u4e4b\u524d\uff0c\u8f93\u5165\u7684\u89d2\u5ea6\u5df2\u7ecf\u8f6c\u6362\u4e3a\u5f27\u5ea6\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">import math\n\nangle = float(input(&quot;\u8bf7\u8f93\u5165\u5f27\u5ea6\u503c\uff1a&quot;))\nsine_value = math.sin(angle)\nprint(&quot;\u6b63\u5f26\u503c\u4e3a\uff1a&quot;, sine_value)\n<\/code><\/pre>\n<p>\u8fd9\u6837\u53ef\u4ee5\u65b9\u4fbf\u5730\u4f7f\u7528\u7528\u6237\u8f93\u5165\u7684\u5f27\u5ea6\u503c\u8fdb\u884c\u8ba1\u7b97\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u8f93\u5165\u5f27\u5ea6\u89d2\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\uff1a\u4f7f\u7528\u5185\u7f6e\u6570\u5b66\u5e93\u4e2d\u7684\u5f27\u5ea6\u51fd\u6570\u3001\u76f4\u63a5\u8f93\u5165\u5f27\u5ea6\u503c\u3001\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\u3002 [&hellip;]","protected":false},"author":3,"featured_media":1003489,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1003475"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1003475"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1003475\/revisions"}],"predecessor-version":[{"id":1003493,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1003475\/revisions\/1003493"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1003489"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1003475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1003475"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1003475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}