Python sin

The Python sin function calculates the Trigonometry Sine for the specified expression. In this section, we discuss how to use sin function in Python Programming language with example.

The mathematical formula behind the Python Trigonometry Sine function is

SIN(x) = Length of the Opposite Side / Length of the Hypotenuse

The Sin function returns the value between -1 and 1. And the syntax of the sin Function in Python Programming Language is

math.sin(number);

Number: It can be a number or a valid numerical expression for which you want to find Sine value.

  • If the number argument is a positive or negative number, sin function returns the Sine value.
  • If it is not a number, sin function returns TypeError.

Python sin Function Example

The Python sin Function allows you to find the trigonometry Sine for the numeric values. In this sin example, we are going to find the Sine values of different data types and display the output

TIP: Please refer Python asin Function article to find the Arc Sine of the specified Python expression.

# Python SIN Function

import math

Tup = (1, 2, 3, -4 , 5)
Lis = [-1, 2, -3.5, -4 , 5]

print('Sine value of Positive Number = %.2f' %math.sin(10))
print('Sine value of Negative Number = %.2f' %math.sin(-15))

print('Sine value of Tuple Item = %.2f' %math.sin(Tup[3]))
print('Sine value of List Item = %.2f' %math.sin(Lis[2]))

print('Sine value of Multiple Number = %.2f' %math.sin(10 + 20 - 40))
print('Sine value of String Number = ', math.sin('Hello'))
Python SIN Function

First, We declared Python List and Tuple with some random values. Next, We used the sin Function directly on both the Positive integer and negative integer. The following statements find the Sine of the corresponding values.

print('Sine value of Positive Number = %.2f' %math.sin(10))
print('Sine value of Negative Number = %.2f' %math.sin(-15))

Next, We used the sin Function on Tuple and List items. If you observe the above screenshot, the Python sin function is working perfectly on them.

print('Sine value of Tuple Item = %.2f' %math.sin(Tup[3]))
print('Sine value of List Item = %.2f' %math.sin(Lis[2]))

Next, We used the sin Math function on multiple values.

print('Sine value of Multiple Number = %.2f' %math.sin(10 + 20 - 40))

Within the last statement, we tried the math sin Function on the String value, and it returns TypeError.

print('Sine value of String Number = ', math.sin('Hello'))