Change language

Python | function math.tan ()

In Python, a math module contains a number of math operations that can be easily accomplished using the module. math.tan() returns the tangent of the value passed as an argument. The value passed to this function must be in radians.

Syntax: math.tan (x)

Parameter:
x: value to be passed to tan ()

Returns: Returns the tangent of value passed as argument

Code # 1:

# Python code for tan () demonstration

 
# import & quot; math & quot; for math operations

import math 

 

a = math.pi / 6

 
# returning the tangent of pi / 6

print ( "The value of tangent of pi / 6 is:" , end = "") 

print (math.tan (a)) 

Code # 2:

# Show Python program
  # Graphical representation
# tan () function

import math

import numpy as np

import matplotlib.pyplot as plt 

 

in_array = np.linspace ( 0 , np.pi, 10

 

out_array = []

 

for i in range ( len (in_array)):

out_array.append (math.tan (in_array [i]))

  i + = 1

 

 

print ( "in_array:" , in_array) 

print ( " out_array: " , out_array) 

  
# red for numpy.sin ()

plt.plot (in_array, out_array, color = ’ red’ < code class = "plain">, marker = "o"

plt.title ( "math.tan ()"

plt.xlabel ( "X"

plt.ylabel ( "Y"

plt.show () 

Exit:

in_array: [0. 0.34906585 0.6981317 1.04719755 1.3962634 1.74532925
2.0943951 2.44346095 2.7925268 3.14159265]

out_array: [0.0, 0.36397023426620234, 0.8390996311772799, 1.7320508075688767, 5.671281819617707, -5.671281819617711, -1.7320508075688783, -0.8390996311772804, -0.36397023426620256, -1.2246467991473532e- 16]

Shop

Gifts for programmers

Learn programming in R: courses

$FREE
Gifts for programmers

Best Python online courses for 2022

$FREE
Gifts for programmers

Best laptop for Fortnite

$399+
Gifts for programmers

Best laptop for Excel

$
Gifts for programmers

Best laptop for Solidworks

$399+
Gifts for programmers

Best laptop for Roblox

$399+
Gifts for programmers

Best computer for crypto mining

$499+
Gifts for programmers

Best laptop for Sims 4

$

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

1947 answers

PythonStackOverflow

Check if one list is a subset of another in Python

1173 answers

PythonStackOverflow

How to specify multiple return types using type-hints

1002 answers

PythonStackOverflow

Printing words vertically in Python

909 answers

PythonStackOverflow

Python Extract words from a given string

798 answers

PythonStackOverflow

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

606 answers

PythonStackOverflow

Python os.path.join () method

384 answers

PythonStackOverflow

Flake8: Ignore specific warning for entire file

360 answers

News


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

Python add suffix / add prefix to strings in a list

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