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 Sine function is the 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


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, it returns TypeError.

Python sin Function Example

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

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

First, We declared 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. Next, We used on Tuple and List items.

If you observe the above screenshot, the Python sin function is working perfectly on them.

Next, We used this math function on multiple values. Within the last statement, we tried on the String value, and it returns TypeError.

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