Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Đọc
Bàn luận math.sin[x]
Trong Python, mô -đun toán học chứa một số thao tác toán học, có thể được thực hiện dễ dàng bằng cách sử dụng mô -đun. Hàm
math.sin[]
Trả về sin giá trị được truyền dưới dạng đối số. Giá trị được truyền trong hàm này nên có trong radian.
x : value to be passed to sin[]Cú pháp: math.sin [x] Returns the sine of value passed as argument
Tham số: x: giá trị được truyền cho sin []
Trả về: Trả về sin của giá trị được thông qua như đối số
Mã số 1:
import
math
math.sin[var]0____11
math.sin[var]2
math.sin[var]3
math.sin[var]4
Output:
The value of sine of pi/6 is : 0.49999999999999994
math.sin[var]5
math.sin[var]6
math.sin[var]7
math.sin[var]8
math.sin[var]1
Code #2:
math.sin[var]5
import math var = 0.36 print[math.sin[var]]2
& nbsp; mã số 2:
import
import math var = 0.36 print[math.sin[var]]4
import math a1 = 0.36 b1 = 1 c1 = -1 d1 = -0.36 print["Value for parameter ", a1, " is ", math.sin[a1]] print["Value for parameter ", b1, " is ", math.sin[b1]] print["Value for parameter ", c1, " is ", math.sin[c1]] print["Value for parameter ", d1, " is ", math.sin[d1]]9
import math a1 = 0.36 b1 = 1 c1 = -1 d1 = -0.36 print["Value for parameter ", a1, " is ", math.sin[a1]] print["Value for parameter ", b1, " is ", math.sin[b1]] print["Value for parameter ", c1, " is ", math.sin[c1]] print["Value for parameter ", d1, " is ", math.sin[d1]]7
import math a1 = 0.36 b1 = 1 c1 = -1 d1 = -0.36 print["Value for parameter ", a1, " is ", math.sin[a1]] print["Value for parameter ", b1, " is ", math.sin[b1]] print["Value for parameter ", c1, " is ", math.sin[c1]] print["Value for parameter ", d1, " is ", math.sin[d1]]2
import math a1 = 0.36 b1 = 1 c1 = -1 d1 = -0.36 print["Value for parameter ", a1, " is ", math.sin[a1]] print["Value for parameter ", b1, " is ", math.sin[b1]] print["Value for parameter ", c1, " is ", math.sin[c1]] print["Value for parameter ", d1, " is ", math.sin[d1]]4
Value for parameter 0.36 is 0.35227423327508994 Value for parameter 1 is 0.8414709848078965 Value for parameter -1 is -0.8414709848078965 Value for parameter -0.36 is -0.352274233275089943
import math a1 = 0.36 b1 = 1 c1 = -1 d1 = -0.36 print["Value for parameter ", a1, " is ", math.sin[a1]] print["Value for parameter ", b1, " is ", math.sin[b1]] print["Value for parameter ", c1, " is ", math.sin[c1]] print["Value for parameter ", d1, " is ", math.sin[d1]]1
Value for parameter 0.36 is 0.35227423327508994 Value for parameter 1 is 0.8414709848078965 Value for parameter -1 is -0.8414709848078965 Value for parameter -0.36 is -0.352274233275089945
import
import math var = 0.36 print[math.sin[var]]6
Các
import math a = 'Hello' print[math.cos[a]]6
import math a = 'Hello' print[math.cos[a]]7
Value for parameter 0.36 is 0.35227423327508994 Value for parameter 1 is 0.8414709848078965 Value for parameter -1 is -0.8414709848078965 Value for parameter -0.36 is -0.352274233275089946
math.sin[var]1
Value for parameter 0.36 is 0.35227423327508994 Value for parameter 1 is 0.8414709848078965 Value for parameter -1 is -0.8414709848078965 Value for parameter -0.36 is -0.352274233275089948
math.sin[var]5
math.sin[var]6
For output: TypeError: must be real number, not str5
For output: TypeError: must be real number, not str6
math.sin[var]5
math.sin[var]6
For output: TypeError: must be real number, not str9
math.sin[]
0Value for parameter 0.36 is 0.35227423327508994 Value for parameter 1 is 0.8414709848078965 Value for parameter -1 is -0.8414709848078965 Value for parameter -0.36 is -0.352274233275089949
import math a = 'Hello' print[math.cos[a]]0
import math a = 'Hello' print[math.cos[a]]1
import math a = 'Hello' print[math.cos[a]]2
math.sin[var]6
import math a = 'Hello' print[math.cos[a]]4
import math a = 'Hello' print[math.cos[a]]5
math.sin[]
8math.sin[]
9math.sin[]
7
import
1import
2math.sin[]
7
import
4import
5math.sin[]
7
import
7
Output:
import math a = 'Hello' print[math.cos[a]]6import math a = 'Hello' print[math.cos[a]]0For output: TypeError: must be real number, not str0math.sin[var]1For output: TypeError: must be real number, not str2
math.sin[]
1math.sin[var]1math.sin[]
3math.sin[]
4math.sin[var]1math.sin[]
6math.sin[]
7
Trong Python, mô -đun toán học chứa một số thao tác toán học, có thể dễ dàng thực hiện bằng mô -đun. Hàm math.sin [] trả về một sin của giá trị được truyền dưới dạng đối số. Giá trị được đưa ra trong hàm sin [] nên có trong radian.math.sin[] function returns a sine of the value passed as an argument. The value given in the sin[] function should be in radians.
Python sin [] là một toán học tích hợp được sử dụng để tìm giá trị hình sin của tham số được truyền trong radian. Hàm sin [] chấp nhận x làm tham số và trả về giá trị sin của x trong radian. is a built-in math function that is used to find the sine value of the parameter passed in radians. The sin[] function accepts x as a parameter and returns the sine value of x in radians.
Chúng ta có thể sử dụng một mô -đun toán học bằng cách nhập nó. Cú pháp sẽ là nhập khẩu toán học; Sau khi nhập, chúng tôi gọi hàm sin [] bằng một đối tượng tĩnh.import math; after importing, we call the sin[] function using a static object.
Cú pháp
math.sin[var]
Ở đây VAR là biến số mà chúng ta phải tìm.
Thông số
Phải mất một tham số var, lấy các giá trị của kiểu dữ liệu số và ném typeerror & nbsp; nếu một đối số của bất kỳ loại dữ liệu nào khác được truyền.TypeError if an argument of any other data type is passed.
Giá trị trả về
Nó trả về giá trị sin của số trong kiểu dữ liệu float.
Xem ví dụ sau.
import math var = 0.36 print[math.sin[var]]
Các chương trình ví dụ về phương pháp sin [] trong Python
Ví dụ 1: Viết một chương trình để hiển thị hoạt động của phương thức Sin [] trong Python.
import math a1 = 0.36 b1 = 1 c1 = -1 d1 = -0.36 print["Value for parameter ", a1, " is ", math.sin[a1]] print["Value for parameter ", b1, " is ", math.sin[b1]] print["Value for parameter ", c1, " is ", math.sin[c1]] print["Value for parameter ", d1, " is ", math.sin[d1]]
Đầu ra
Value for parameter 0.36 is 0.35227423327508994 Value for parameter 1 is 0.8414709848078965 Value for parameter -1 is -0.8414709848078965 Value for parameter -0.36 is -0.35227423327508994
Trong ví dụ này, chúng tôi đã thấy rằng bằng cách chuyển một tham số hợp lệ khác nhau cho các ví dụ khác nhau, chúng tôi có được giải pháp Phương thức Sin [] mong muốn, đó là giá trị hình sin của tham số.
Ví dụ 2: Viết một chương trình để chuyển giá trị ra khỏi phạm vi từ hàm sin [] và hiển thị đầu ra.
Xem ví dụ sau.
import math a = 'Hello' print[math.cos[a]]
Đầu ra
For output: TypeError: must be real number, not str
Trong ví dụ này, chúng tôi đã thấy rằng bằng cách chuyển một tham số hợp lệ khác nhau cho các ví dụ khác nhau, chúng tôi có được giải pháp Phương thức Sin [] mong muốn, đó là giá trị hình sin của tham số.
Ví dụ 2: Viết một chương trình để chuyển giá trị ra khỏi phạm vi từ hàm sin [] và hiển thị đầu ra.
Trong ví dụ này, chúng tôi đã thấy rằng việc truyền một tham số, không phải là một số thực, ném một kiểu mẫu. sin[] function is used to find the sine of a given argument in radians, where sine is a trigonometric function that represents the ratio between hypotenuse and opposite.
Sự kết luận
Hàm pythonsin [] được sử dụng để tìm sin của một đối số nhất định trong radian, trong đó sin là một hàm lượng giác đại diện cho tỷ lệ giữa các hypotenuse và ngược lại.
Xem thêm
Python Hypot []
Python Atan []
Python atan2 []