Thursday, September 4, 2025
HomeLanguagesPython – cmath.tan() function

Python – cmath.tan() function

cmath is Python built-in module that is used for complex number mathematics. cmath module has a method tan() that returns tangent of the complex number passed to it.

Syntax: cmath.tan(Z)

Parameter: It requires only one parameter i.e the number for which tangent needs to be calculated.

Return: Returns a complex number that is the tangent of the number passed.

Example 1: 

Python3




# Import the Library
import cmath 
  
# Printing the result
print (cmath.tan(5 + 3j))


Output:

(-0.002708235836224072+1.0041647106948153j)

Example 2: In this example real number is passed but the returned result is still a complex number.

Python3




# Import the Library
import cmath 
  
# Printing the result
print (cmath.tan(1))


Output:

(1.5574077246549023+0j)

Example 3: In this example no argument is passed in this case TypeError will be thrown

Python3




# Import the Library
import cmath 
  
# Printing the result
print (cmath.tan())


Output:

TypeError: tan() takes exactly one argument (0 given)
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32261 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6626 POSTS0 COMMENTS
Nicole Veronica
11795 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11855 POSTS0 COMMENTS
Shaida Kate Naidoo
6747 POSTS0 COMMENTS
Ted Musemwa
7023 POSTS0 COMMENTS
Thapelo Manthata
6695 POSTS0 COMMENTS
Umr Jansen
6714 POSTS0 COMMENTS