A. python里cos30度
這些函數的單位是弧度,不是角度。
30度角度換算成弧度是(pi/6);
用numpy.sin(numpy.PI/6)或numpy.sin(3.1415926/6)
餘弦也是cos..
如果僅僅是入門級或輕量級的計算用Math.cos就可以了,numpy顯得很重型
B. python Turtle如何繪制任意弧度的曲線
要畫弧線自然需要用到正餘弦函數
C. sin15°用Python怎麼表示
Python的三角函數sin(),輸入參數必須是弧度,所以要把角度變換為弧度
import math
# .... 輸入度數到 degrees 變數....
# 例子里用 30度計算
degrees=30
radians = degrees * math.pi / 180.0
value = round( math.sin(radians), 4)
print(value)
D. Python中計算三角函數之cos()方法的使用簡介
這篇文章主要介紹了Python中計算三角函數之cos()方法的使用簡介,是Python入門的基礎知識,需要的朋友可以參考下
cos()方法返回x弧度的餘弦值。
語法
以下是cos()方法的語法:
cos(x)
注意:此函數是無法直接訪問的,所以我們需要導入math模塊,然後需要用math的靜態對象來調用這個函數。
參數
x
--
這必須是一個數值
返回值
此方法返回-1
到
1之間的數值,它表示角度的餘弦值
例子
下面的例子展示cos()方法的使用
?
1
2
3
4
5
6
7
8#!/usr/bin/python
import
math
print
"cos(3)
:
",
math.cos(3)
print
"cos(-3)
:
",
math.cos(-3)
print
"cos(0)
:
",
math.cos(0)
print
"cos(math.pi)
:
",
math.cos(math.pi)
print
"cos(2*math.pi)
:
",
math.cos(2*math.pi)
當我們運行上面的程序,它會產生以下結果:
?
1
2
3
4
5cos(3)
:
-0.9899924966
cos(-3)
:
-0.9899924966
cos(0)
:
1.0
cos(math.pi)
:
-1.0
cos(2*math.pi)
:
1.0
E. 如何用python表示三角函數
Python編碼下面的三角函數包括以下種類:acos(x)//返回x的反餘弦弧度值。asin(x)//返回x的反正弦弧度值。atan(x)//返回x的反正切弧度值。atan2(y,x)//返回給定的X及Y坐標值的反正切值。cos(x)//返回x的弧度的餘弦值。hypot(x,y
描述
sin()返回的x弧度的正弦值。
語法
以下是sin()方法的語法:
importmath
math.sin(x)
注意:sin()是不能直接訪問的,需要導入math模塊,然後通過math靜態對象調用該方法。
參數
x--一個數值。
返回值
返回的x弧度的正弦值,數值在-1到1之間。
實例
以下展示了使用sin()方法的實例:
#!/usr/bin/python
import math
print "sin(3) : ", math.sin(3)
print "sin(-3) : ", math.sin(-3)
print "sin(0) : ", math.sin(0)
print "sin(math.pi) : ", math.sin(math.pi)
print "sin(math.pi/2) : ", math.sin(math.pi/2)
以上實例運行後輸出結果為:
sin(3) : 0.14112000806
sin(-3) : -0.14112000806
sin(0) : 0.0
sin(math.pi) : 1.22460635382e-16
sin(math.pi/2) : 1
總結
以上就是本文關於Python入門之三角函數sin()函數實例詳解的全部內容,希望對大家有所幫助。感興趣的朋友可以繼續參閱本站:python正則表達式re之compile函數解析、Python中enumerate函數代碼解析、簡單了解Python中的幾種函數等,有什麼問題可以隨時留言,小編會及時回復大家的。感謝朋友們對本站的支持!
F. 在Python中怎麼計算編寫程序,輸出0~90°之間(包括端點)每隔5°時的角度值以
用for循環和range()即可:
望採納!!!
G. python「半圓弧的長度」輸入圓的半徑,求半圓弧的長度(使用math庫的pi常量)
具體代碼如下:
>>> from math import pi
>>> r = float(input("請輸入圓的半徑:")) #設置鍵盤輸入
請輸入圓的半徑:2
>>> l = round(pi*r, 2) #計算半圓弧長,保留兩位小數
>>> print("L=%s"%str(l), end='') # 無空行輸出
L=6.28
>>>