OKPEDIA PYTHON TRIGONOMETRIA EN

How to calculate sine in Python

To calculate the sine function in the python language, use the sin function of the math module.

import math
math.sin(x)

The parameter x is the input argument of the sine function and identifies the angle expressed in radians.

The sin(x) function returns the sine of x.

What is the sine function? In trigonometry the sine is the ratio between the cathetus opposite the angle (AB) and the hypotenuse (OB). The sine is equal to zero if the angle α has 0 degrees. The sine is equal to 1 if the angle α has 90 ° degrees.
sin function

Example

Example 1

An angle of 90 ° is π / 2

In the math module, pi (π) is the constant math.pi

This function calculates the sine.

import math
x=math.pi/2
math.sin(x)

The function returns the value one

1.0

The sine of π/2 is 1.

Example 2

An angle of 45 ° is π/4 radians

In this example, we use the math.radians () function to directly convert the degrees of the angle to radians, without using pi.

import math
x=math.radians(45)
math.sin(x)

The function outputs the following result

0.7071067811865475

The sine of an angle of 45 degrees ( π/4 radianti ) is 0.7071.

https://how.okpedia.org/en/python/how-to-calculate-sine-in-python


Report an error or share a suggestion to enhance this page


How to find in Python


FacebookTwitterLinkedinLinkedin