window.ENTITIES={'/api/snippets/python/python%20math.cos()%20working%20with%20degrees':[{"result":true,"message":null,"batch":{"type":"python","name":"python math.cos() working with degrees","items":[{"id":"jv36l1","type":"python","name":"Python math.cos() working with degrees","content":"import math\n\n\ndef calculate_cos(deg):\n rad = (math.pi / 180) * deg\n return math.cos(rad)\n\n\nx1 = 0.0 # beginning of calculation in degrees\nx2 = 90.0 # ending of calculation degrees\n\ndx = 15.0 # calculation step in degrees\n\ndeg = x1\n\nwhile deg <= x2:\n y = calculate_cos(deg)\n print(\"cos(\", deg, \" deg) = \", y)\n deg += dx\n\n\n\n# Output:\n# cos( 0.0 deg) = 1.0\n# cos( 15.0 deg) = 0.9659258262890683\n# cos( 30.0 deg) = 0.8660254037844387\n# cos( 45.0 deg) = 0.7071067811865476\n# cos( 60.0 deg) = 0.5000000000000001\n# cos( 75.0 deg) = 0.25881904510252074\n# cos( 90.0 deg) = 6.123233995736766e-17","source":"https://dirask.com/posts/Python-math-cos-method-example-1RvPG1","author":{"id":"5073Q0","name":"Antonina-Trejo","avatar":"1629129355505__5073Q0__w40px_h40px.jpg","points":387,"role":"BASIC"},"creationTime":1634835624000,"updateTime":null,"removalTime":null}]}}]};