[英]How can I take cosine of a variable in python?
我正在尝试制作一个程序,该程序将在某个角度找到所施加力的 x 和 y 分量。 这是我到目前为止所拥有的。 当我运行它时,我得到一个错误,基本上说你不能取一个变量的余弦,它必须是一个实数。 我将如何使这种类型的程序工作?
Import math
Angle = input("Enter angle:")
Force = 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)
这是修复大写并将输入值的类型更改为浮点数后的代码:
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.