Python math.sin()เมธอด
ตัวอย่าง
ค้นหาไซน์ของตัวเลขต่างๆ:
# Import math Library
import math
# Return the sine of different
values
print (math.sin(0.00))
print (math.sin(-1.23))
print (math.sin(10))
print (math.sin(math.pi))
print
(math.sin(math.pi/2))
ความหมายและการใช้งาน
math.sin()
เมธอดจะคืนค่าไซน์ของตัวเลข
หมายเหตุ:ในการหาไซน์ขององศา ก่อนอื่นจะต้องแปลงเป็นเรเดียนด้วยวิธีดังกล่าว (ดูตัวอย่างด้านล่าง)
math.radians()
ไวยากรณ์
math.sin(x)
ค่าพารามิเตอร์
Parameter | Description |
---|---|
x | Required. The number to find the sine of. If the value is not a number, it returns a TypeError |
รายละเอียดทางเทคนิค
คืนมูลค่า: | ค่าfloat ตั้งแต่ -1 ถึง 1 แทนค่าไซน์ของมุม |
---|---|
เวอร์ชันหลาม: | 1.4 |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
ค้นหาไซน์ขององศาต่างๆ:
# Import math Library
import math
# Return the sine value of 30
degrees
print(math.sin(math.radians(30)))
# Return the sine value
of 90 degrees
print(math.sin(math.radians(90)))