您好,我有一個方程式,我正在嘗試使用 python 計算。我正在尋找的所需輸出在哪里1.71528
下面我有我當前的代碼,所有當前值 d 應該等于 100,theta 應該等于 60。
import math
m = 0.065
g = 9.8
print("Input the distance to professor")
d = 100 # float(input())
k = 25
print("Now input the value for theta")
theta = 60 # float(input())
x = math.sqrt(m*g*d/k*math.sin(2 * theta))
print(x, 'meters')
運行此代碼時得到的輸出是 1.2163047715819324 meters
我認為我的問題與 math.sin 有關,任何幫助將不勝感激。
uj5u.com熱心網友回復:
將 theta 轉換為弧度并在分母周圍加上括號。
x = math.sqrt(m*g*d/(k*math.sin(2 * math.radians(theta))))
print(f"{x:.5f} meters")
會導致
Input the distance to professor
100
Now input the value for theta
60
1.71528 meters
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/412104.html
標籤:
