Change language

# Math Functions in Python | Set 3 (trigonometric and angle functions)

|

1. sin () : — This function returns the sine of the value passed as an argument. The value passed to this function must be in radians .

2. cos () : — This function returns the cosine of the value passed as an argument. The value passed to this function must be in radians .

 ` # Python code to demonstrate how it works ` ` # sin () and cos () `   ` # import math for math operations ` ` import ` ` math `   ` a ` ` = ` ` math.pi ` ` / ` ` 6 `   ` # returns sine pi / 6 ` ` print ` ` (` ` "The value of sine of pi / 6 is:" ` `, end ` ` = ` ` "") ` ` print ` ` (math.sin (a)) `   ` # returns cosine pi / 6 value ` ` print ` ` (` ` "The value of cosine of pi / 6 is:" ` , end ` = ` ` "") ` ` print ` ` (math.cos (a)) `

Output:

` The value of sine of pi / 6 is: 0.49999999999999994 The value of cosine of pi / 6 is: 0.8660254037844387 `

3. tan () : — This function returns the tangent of the value passed as an argument. The value passed to this function must be in radians .

4. hypot (a, b) : — returns the hypotenuse of the values ​​passed in the arguments. Returns numerically sqrt (a * a + b * b) .

 ` # Python code to demonstrate how it works ` ` # tan () and hypot () `   ` # import math for math operations ` ` import ` ` math `   ` a ` ` = ` ` math.pi ` ` / ` ` 6 ` ` b ` ` = ` ` 3 ` ` c ` ` = ` ` 4 `   ` # returning the tangent of pi / 6 ` ` print ` ` (` ` "The value of tangent of pi / 6 is:" ` `, end ` ` = ` ` "") ` ` print ` ` (math. tan (a)) `   # returns hypotenuse 3 and 4 ` print ` ` (` ` "The value of hypotenuse of 3 and 4 is:" ` `, end ` ` = ` ` "") ` ` print ` ` (math.hypot ( b, c)) `

Output:

` The value of tangent of pi / 6 is: 0.5773502691896257 The value of hypotenuse of 3 and 4 is: 5.0 `

5. degrees () : — This function is used to convert the argument value from radians to degrees .

6. radians () : — This function is used to convert the argument value from degrees to radians .

 ` # Python code to demonstrate how it works ` ` # degrees () and radians () `   ` # import math for math operations ` ` import ` ` math `   ` a ` ` = ` ` math.pi ` ` / ` ` 6 ` ` b ` ` = ` ` 30 `   ` # returns the converted value from radians to degrees ` ` print ` ` (` `" The converted value from radians to degrees is: "` `, end ` ` = ` `" ") ` ` print ` ` (math.degrees (a)) `   ` # returns the converted value from degrees to radians ` ` print ` ` (` ` " The converted value from degrees to radians is: "` `, end ` ` = ` `" ") ` ` print ` ` (math.radians (b)) `

Output:

` The converted value from radians to degrees is: 29.999999999999996 The converted value from degrees to radians is: 0.5235987755982988 `

This article courtesy of Manjit Singh . If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.

## Shop

Learn programming in R: courses

\$

Best Python online courses for 2022

\$

Best laptop for Fortnite

\$

Best laptop for Excel

\$

Best laptop for Solidworks

\$

Best laptop for Roblox

\$

Best computer for crypto mining

\$

Best laptop for Sims 4

\$

Latest questions

NUMPYNUMPY

Common xlabel/ylabel for matplotlib subplots

NUMPYNUMPY

How to specify multiple return types using type-hints

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

NUMPYNUMPY

glob exclude pattern

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

NUMPYNUMPY

Python CSV error: line contains NULL byte

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

## Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically