Python มาพร้อม math library มาตรฐานที่มีฟังก์ชันตรีโกนometri sin, cos ฯลฯ import แล้วใช้ได้ ฟังก์ชันเหล่านี้คาดหวังมุมในเรเดียน
import math angle1 = math.radians(90) angle2 = math.radians(60) print(math.cos(angle1)) print(math.cos(angle2))
ผลลัพธ์:
6.123233995736766e-17 0.5
ค่าแรกใกล้ศูนย์มาก Error มาจากข้อจำกัดการคำนวณ