如何在python中获取变量的余弦值?

时间:2018-11-12 17:24:59

标签: python python-3.x components sin cosine

我正在尝试编写一个程序,以某个角度查找施加力的x和y分量。这是我到目前为止所拥有的。当我运行它时,我得到一个错误,该错误基本上表明您不能接受变量的余弦,并且它必须是实数。我将如何使这种程序起作用?


if(cust?.ID == null)
{
    lstDisplay.items.Add("Customer details not stored")
}

1 个答案:

答案 0 :(得分:0)

固定大小写并将输入值的类型更改为浮点后的代码如下:

import math
angle = float(input("Enter angle:"))
force = float(input("Enter applied force:"))
x = math.cos(angle)
y = x * force
print("The x component of the applied force is", y)
b = math.cos(angle)
a = b * force
print("The y component of the applied force is", a)