본문 바로가기
Python

[Python] 삼각함수(sin, cos, tan)

by 기리의 개발로그 2024. 3. 7.

삼각 함수(sin, cos, tan)

sin 함수 는 사인(sin) 값을 반환하는 함수이다.
cos 함수 는 코사인(cos) 값을 반환하는 함수이다.
tan 함수 는 탄젠트(tan) 값을 반환하는 함수이다.

sin(x)
cos(x)
tan(x)
  • x : 삼각함수 값을 구할 라디안(각도) 값

sin, cos, tan 삼각함수를 사용하기 위해서는 math 모듈을 import 해야한다.


삼각 함수 예제


import math

degrees = [0, 30, 45, 60, 90]

for de in degrees:
    a = math.sin(math.pi * (de / 180))
    b = math.cos(math.pi * (de / 180))
    c = math.tan(math.pi * (de / 180))

    print(f"sin({de:2d}) : {a:.4f}")
    print(f"cos({de:2d}) : {a:.4f}")
    print(f"tan({de:2d}) : {a:.4f}")
sin(0) : 0.0000
cos(0) : 1.0000
tan(0) : 0.0000

sin(30) : 0.5000
cos(30) : 0.8660
tan(30) : 0.5774

sin(45) : 0.7071
cos(45) : 0.7071
tan(45) : 1.0000

sin(60) : 0.8660
cos(60) : 0.5000
tan(60) : 1.7321

sin(90) : 1.0000
cos(90) : 0.0000
tan(90) : 16331239353195370.0000
반응형

'Python' 카테고리의 다른 글

[Python] sorted() 함수  (69) 2024.03.11
[Python] degree(), radian() 함수  (77) 2024.03.08
[Python] isdecimal() 함수  (77) 2024.03.06
[Python] isalpha() 함수  (86) 2024.03.05
[Python] isdigit() 함수  (82) 2024.03.04

댓글