Python math.sin() Metode
Contoh
Temukan sinus dari bilangan yang berbeda:
# 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))
Definisi dan Penggunaan
Metode math.sin()
mengembalikan sinus angka.
Catatan: Untuk mencari sinus derajat, terlebih dahulu harus diubah menjadi radian dengan metode (lihat contoh di bawah).
math.radians()
Sintaksis
math.sin(x)
Nilai Parameter
Parameter | Description |
---|---|
x | Required. The number to find the sine of. If the value is not a number, it returns a TypeError |
Detail Teknis
Nilai Kembali: | Nilai float , dari -1 hingga 1, mewakili sinus sudut |
---|---|
Versi Python: | 1.4 |
Lebih Banyak Contoh
Contoh
Cari sinus derajat yang berbeda:
# 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)))